tuxbot-bot/utils/models/poll.py

28 lines
714 B
Python
Raw Normal View History

from . import Base
2019-10-14 00:12:47 +02:00
from sqlalchemy import Column, Integer, BigInteger, JSON, ForeignKey, Boolean
from sqlalchemy.orm import relationship
2019-12-30 00:48:11 +01:00
class PollModel(Base):
__tablename__ = 'polls'
id = Column(Integer, primary_key=True, autoincrement=True)
channel_id = Column(BigInteger)
message_id = Column(BigInteger)
content = Column(JSON)
2019-10-14 00:12:47 +02:00
is_anonymous = Column(Boolean)
2019-10-14 00:12:47 +02:00
available_choices = Column(Integer)
2019-12-30 00:48:11 +01:00
choice = relationship("ResponsesModel")
2019-12-30 00:48:11 +01:00
class ResponsesModel(Base):
__tablename__ = 'responses'
id = Column(Integer, primary_key=True, autoincrement=True)
2019-10-14 00:12:47 +02:00
user = Column(BigInteger)
poll_id = Column(Integer, ForeignKey('polls.id'))
choice = Column(Integer)