Conversation.py 580 B

1234567891011121314151617
  1. from .Base import Base
  2. from datetime import datetime
  3. from sqlalchemy.orm import relationship
  4. from sqlalchemy import Column, Integer, ForeignKey, DateTime, String
  5. class Conversation(Base):
  6. __tablename__ = "conversations"
  7. id = Column(Integer, primary_key=True)
  8. user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
  9. created_at = Column(DateTime, default=datetime.now)
  10. summary = Column(String(50), nullable=False)
  11. user = relationship("User", back_populates="conversations")
  12. messages = relationship("Message", back_populates="conversation")