| 48 | ) |
| 49 | |
| 50 | class Post(Base): |
| 51 | __tablename__ = 'posts' |
| 52 | |
| 53 | id = Column(Integer, primary_key=True) |
| 54 | title = Column(String(200), nullable=False) |
| 55 | content = Column(Text) |
| 56 | author_id = Column(Integer, ForeignKey('users.id')) |
| 57 | view_count = Column(Integer, default=0) |
| 58 | rating = Column(Float) |
| 59 | published = Column(Boolean, default=False) |
| 60 | published_at = Column(DateTime) |
| 61 | tags = Column(JSON) |
| 62 | |
| 63 | # Relationships |
| 64 | author = relationship("User", back_populates="posts") |
| 65 | comments = relationship("Comment", back_populates="post", cascade="all, delete-orphan") |
| 66 | |
| 67 | class Comment(Base): |
| 68 | __tablename__ = 'comments' |
no outgoing calls