Atualizar app/models.py
This commit is contained in:
@@ -1,3 +1,37 @@
|
||||
from sqlalchemy import Column, String, Text, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import declarative_base, relationship
|
||||
from datetime import datetime
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
class Conversation(Base):
|
||||
__tablename__ = "conversations"
|
||||
id = Column(String, primary_key=True)
|
||||
user_email = Column(String, index=True) # filter by user
|
||||
title = Column(String)
|
||||
messages = relationship("Message", back_populates="conversation")
|
||||
attachments = relationship("Attachment", back_populates="conversation")
|
||||
|
||||
class Message(Base):
|
||||
__tablename__ = "messages"
|
||||
id = Column(String, primary_key=True)
|
||||
conversation_id = Column(String, ForeignKey("conversations.id"))
|
||||
role = Column(String)
|
||||
content = Column(Text)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
conversation = relationship("Conversation", back_populates="messages")
|
||||
|
||||
class Attachment(Base):
|
||||
__tablename__ = "attachments"
|
||||
id = Column(String, primary_key=True)
|
||||
conversation_id = Column(String, ForeignKey("conversations.id"))
|
||||
filename = Column(String)
|
||||
mime_type = Column(String)
|
||||
path = Column(String) # /data/<uuid>
|
||||
conversation = relationship("Conversation", back_populates="attachments")
|
||||
|
||||
# ***
|
||||
|
||||
from sqlalchemy import Column, String, Boolean, Text, DateTime, Integer
|
||||
from datetime import datetime
|
||||
from db import Base
|
||||
|
||||
Reference in New Issue
Block a user