1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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 '<User %r>' % (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 '<Ticket %r>' % (self.id)
|