class Answer(db.Model): id = db.Column(db.Integer, primary_key=True) question_id = db.Column(db.Integer, db.ForeignKey('question.id', ondelete='CASCADE')) question = db.relationship('Question', backref=db.backref('answer_set')) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False)
class Content(db.Model): id = db.Column(db.Integer, primary_key=True) writer = db.Column(db.String(20), nullable=False) title = db.Column(db.String(20), nullable=False) content = db.Column(db.Text, nullable=False) category_id = db.Column(db.Integer, db.ForeignKey("category.id"), nullable=False) category = db.relationship("Category", backref=db.backref("contents"))
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"