-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.py
27 lines (22 loc) · 1.09 KB
/
tables.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
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import relationship
from flask_login import UserMixin
db = SQLAlchemy()
# Creating database tables
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(250), nullable=False)
email = db.Column(db.String(250), unique=True, nullable=False)
password = db.Column(db.String(500), nullable=False)
todo_list = relationship('Todo', back_populates='user')
class Todo(db.Model):
id = db.Column(db.Integer, primary_key=True)
task = db.Column(db.String(250), nullable=False)
estimated_end_date = db.Column(db.DateTime, nullable=False)
start_date = db.Column(db.DateTime, nullable=True)
task_started = db.Column(db.Boolean, default=False, nullable=False)
end_date = db.Column(db.DateTime, nullable=True)
task_finished = db.Column(db.Boolean, default=False, nullable=False)
archived = db.Column(db.Boolean, default=False, nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
user = relationship('User', back_populates='todo_list')