| 65 | comments = relationship("Comment", back_populates="post", cascade="all, delete-orphan") |
| 66 | |
| 67 | class Comment(Base): |
| 68 | __tablename__ = 'comments' |
| 69 | |
| 70 | id = Column(Integer, primary_key=True) |
| 71 | post_id = Column(Integer, ForeignKey('posts.id')) |
| 72 | user_id = Column(Integer, ForeignKey('users.id')) |
| 73 | content = Column(Text) |
| 74 | created_at = Column(DateTime, default=func.now()) |
| 75 | |
| 76 | # Relationships |
| 77 | post = relationship("Post", back_populates="comments") |
| 78 | user = relationship("User") |
| 79 | |
| 80 | class TestRunner: |
| 81 | def __init__(self, connection_string: str): |