2019-10-06 01:49:30 +02:00
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
2019-10-14 00:12:47 +02:00
|
|
|
from sqlalchemy import Column, Integer, BigInteger, JSON, ForeignKey, Boolean
|
2019-10-09 00:14:43 +02:00
|
|
|
from sqlalchemy.orm import relationship
|
2019-10-14 00:12:47 +02:00
|
|
|
from werkzeug.security import generate_password_hash, check_password_hash
|
2019-10-06 01:49:30 +02:00
|
|
|
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
|
|
|
|
|
|
class Poll(Base):
|
|
|
|
__tablename__ = 'polls'
|
|
|
|
|
2019-10-09 00:14:43 +02:00
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
2019-10-06 23:49:00 +02:00
|
|
|
channel_id = Column(BigInteger)
|
2019-10-06 01:49:30 +02:00
|
|
|
message_id = Column(BigInteger)
|
2019-10-09 00:14:43 +02:00
|
|
|
|
2019-10-06 23:49:00 +02:00
|
|
|
content = Column(JSON)
|
2019-10-14 00:12:47 +02:00
|
|
|
is_anonymous = Column(Boolean)
|
2019-10-09 00:14:43 +02:00
|
|
|
|
2019-10-14 00:12:47 +02:00
|
|
|
available_choices = Column(Integer)
|
2019-10-09 00:14:43 +02:00
|
|
|
choice = relationship("Responses")
|
|
|
|
|
|
|
|
|
|
|
|
class Responses(Base):
|
|
|
|
__tablename__ = 'responses'
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
2019-10-14 00:12:47 +02:00
|
|
|
user = Column(BigInteger)
|
2019-10-09 00:14:43 +02:00
|
|
|
|
|
|
|
poll_id = Column(Integer, ForeignKey('polls.id'))
|
|
|
|
choice = Column(Integer)
|