2023-05-15 08:51:32 +08:00
|
|
|
from extensions.ext_database import db
|
2024-08-13 14:44:10 +08:00
|
|
|
|
|
|
|
from .model import Message
|
|
|
|
from .types import StringUUID
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
class SavedMessage(db.Model):
|
2024-09-10 17:08:06 +08:00
|
|
|
__tablename__ = "saved_messages"
|
2023-05-15 08:51:32 +08:00
|
|
|
__table_args__ = (
|
2024-09-10 17:08:06 +08:00
|
|
|
db.PrimaryKeyConstraint("id", name="saved_message_pkey"),
|
|
|
|
db.Index("saved_message_message_idx", "app_id", "message_id", "created_by_role", "created_by"),
|
2023-05-15 08:51:32 +08:00
|
|
|
)
|
|
|
|
|
2024-09-10 17:08:06 +08:00
|
|
|
id = db.Column(StringUUID, server_default=db.text("uuid_generate_v4()"))
|
2024-04-29 11:58:17 +08:00
|
|
|
app_id = db.Column(StringUUID, nullable=False)
|
|
|
|
message_id = db.Column(StringUUID, nullable=False)
|
2023-05-25 15:54:45 +08:00
|
|
|
created_by_role = db.Column(db.String(255), nullable=False, server_default=db.text("'end_user'::character varying"))
|
2024-04-29 11:58:17 +08:00
|
|
|
created_by = db.Column(StringUUID, nullable=False)
|
2024-09-10 17:08:06 +08:00
|
|
|
created_at = db.Column(db.DateTime, nullable=False, server_default=db.text("CURRENT_TIMESTAMP(0)"))
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def message(self):
|
|
|
|
return db.session.query(Message).filter(Message.id == self.message_id).first()
|
|
|
|
|
|
|
|
|
|
|
|
class PinnedConversation(db.Model):
|
2024-09-10 17:08:06 +08:00
|
|
|
__tablename__ = "pinned_conversations"
|
2023-05-15 08:51:32 +08:00
|
|
|
__table_args__ = (
|
2024-09-10 17:08:06 +08:00
|
|
|
db.PrimaryKeyConstraint("id", name="pinned_conversation_pkey"),
|
|
|
|
db.Index("pinned_conversation_conversation_idx", "app_id", "conversation_id", "created_by_role", "created_by"),
|
2023-05-15 08:51:32 +08:00
|
|
|
)
|
|
|
|
|
2024-09-10 17:08:06 +08:00
|
|
|
id = db.Column(StringUUID, server_default=db.text("uuid_generate_v4()"))
|
2024-04-29 11:58:17 +08:00
|
|
|
app_id = db.Column(StringUUID, nullable=False)
|
|
|
|
conversation_id = db.Column(StringUUID, nullable=False)
|
2023-05-25 15:54:45 +08:00
|
|
|
created_by_role = db.Column(db.String(255), nullable=False, server_default=db.text("'end_user'::character varying"))
|
2024-04-29 11:58:17 +08:00
|
|
|
created_by = db.Column(StringUUID, nullable=False)
|
2024-09-10 17:08:06 +08:00
|
|
|
created_at = db.Column(db.DateTime, nullable=False, server_default=db.text("CURRENT_TIMESTAMP(0)"))
|