from app import db import datetime class User(db.Model): id = db.Column(db.Integer, primary_key=True) nickname = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) opened = db.relationship('Ticket', backref='opened_by', lazy='dynamic') def __repr__(self): return '' % (self.nickname) class Ticket(db.Model): id = db.Column(db.Integer, primary_key=True) summary = db.Column(db.String(140), nullable=False) body = db.Column(db.Text, nullable=False) opened_at = db.Column(db.DateTime, nullable=False) updated_at = db.Column(db.DateTime) status = db.Column(db.String(64), nullable=False, default='open') reason = db.Column(db.String(140)) opened_by_user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return '' % (self.id)