| 4 | from db.base import Base |
| 5 | |
| 6 | class UserMemoryModel(Base): |
| 7 | __tablename__ = "user_memory" |
| 8 | |
| 9 | id = Column(UUID(as_uuid=False), primary_key=True, comment="记忆ID") |
| 10 | userId = Column(UUID(as_uuid=False), ForeignKey("users.id", ondelete="CASCADE"), name="userId", index=True, comment="用户ID") |
| 11 | memoryText = Column(String(1024), name="memoryText", comment="记忆内容摘要") |
| 12 | importance = Column(Integer, default=1, comment="重要程度 1-5") |
| 13 | lastUsedTime = Column(String(50), name="lastUsedTime", default=func.now(), comment="最近使用时间") |
| 14 | createdAt = Column(String(50), name="createdAt", default=func.now(), comment="创建时间") |
| 15 | metadata_ = Column(JSONB, name="metadata", default={}) |
| 16 | threadId = Column(UUID(as_uuid=False), ForeignKey("threads.id", ondelete="SET NULL"), name="threadId", index=True, comment="线程ID") |
| 17 | |
| 18 | def __repr__(self): |
| 19 | return f"<UserMemory(id='{self.id}', userId='{self.userId}', memoryText='{self.memoryText[:20]}...', importance={self.importance})>" |