-
Notifications
You must be signed in to change notification settings - Fork 0
/
answer.py
26 lines (23 loc) · 930 Bytes
/
answer.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
from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, Table, func
from sqlalchemy.orm import relationship, backref
from sqlalchemy.sql.sqltypes import Boolean
from base import Base
class Answer(Base):
__tablename__ = 'answers'
id = Column(Integer, primary_key=True)
text = Column(String(255))
created_on = Column(DateTime, default=func.now())
question_id = Column(Integer, ForeignKey('questions.id'))
user_id = Column(Integer, ForeignKey('users.id'))
accepted = Column(Boolean, default=True)
# Use cascade='delete,all' to propagate the deletion of a Department onto its Employees
question = relationship(
"Question",
backref=backref('questions',
uselist=True,
cascade='delete,all'))
points = relationship(
"Point",
back_populates="answer",
cascade="delete, merge, save-update"
)