from datetime import datetime

from app import db


class Joke(db.Model):
    """Модель шутки"""

    __tablename__='jokes'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(200), nullable=False)
    """Время написани/редактирования шутки"""
    updated_at = db.Column(db.DateTime, onupdate=datetime.utcnow)
    created_by = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    # def __repr__(self):
    #     return "<Joke {}>".format(self.title)