-
Notifications
You must be signed in to change notification settings - Fork 0
/
question.py
30 lines (27 loc) · 1.12 KB
/
question.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
from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, Table, func
from sqlalchemy.orm import relationship, backref
from sqlalchemy.sql.elements import collate
from base import Base
class Question(Base):
__tablename__ = 'questions'
id = Column(Integer, primary_key=True)
text = Column(String(255,collation="utf8mb4_bin"))
# Use default=func.now() to set the default hiring time
# of an Employee to be the current time when an
# Employee record was created
created_on = Column(DateTime, default=func.now())
position = Column(Integer, default=0)
user_id = Column(Integer, ForeignKey('users.id'))
game_id = Column(Integer, ForeignKey('games.id'))
# Use cascade='delete,all' to propagate the deletion of a Department onto its Employees
game = relationship(
'Game',
backref=backref('games',
uselist=True,
# cascade='delete,all'
))
answers = relationship(
'Answer',
backref=backref('answer',
uselist=True,
cascade='delete,all'))