-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
37 lines (28 loc) · 1.33 KB
/
models.py
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
30
31
32
33
34
35
36
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import func
import datetime
db = SQLAlchemy()
class User(db.Model):
__tablename__ = 'user'
uid = db.Column(db.Integer, primary_key=True, autoincrement=True)
user_name = db.Column(db.String, unique=True, nullable=False)
name = db.Column(db.String, nullable=False)
password = db.Column(db.String, nullable=False)
rel_list = db.relationship("List")
class List(db.Model):
__tablename__ = 'list'
lid = db.Column(db.Integer, primary_key=True, autoincrement=True)
list_name = db.Column(db.String, nullable=False)
description = db.Column(db.String(80), nullable=False)
user_id = db.Column(db.Integer,db.ForeignKey("user.uid"), nullable=False)
cards = db.relationship("Card",cascade="all, delete")
class Card(db.Model):
__tablename__ = 'card'
cid = db.Column(db.Integer, primary_key=True, autoincrement=True)
card_title = db.Column(db.String , nullable = False)
content = db.Column(db.String(120), nullable=False)
deadline = db.Column(db.String, server_default=func.now())
flag = db.Column(db.String)
list_id = db.Column(db.Integer, db.ForeignKey("list.lid"), nullable=False)
last_change=db.Column(db.String, onupdate=datetime.datetime.now())
card_created=db.Column(db.String, server_default=func.now())