41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import uuid
|
|
|
|
from barker.models.meta import Base
|
|
from sqlalchemy import Column, ForeignKey, Unicode, text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import backref, relationship
|
|
|
|
|
|
class Overview(Base):
|
|
__tablename__ = "overview"
|
|
id = Column(
|
|
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), default=uuid.uuid4
|
|
)
|
|
voucher_id = Column(
|
|
"voucher_id",
|
|
UUID(as_uuid=True),
|
|
ForeignKey("vouchers.id"),
|
|
nullable=False,
|
|
unique=True,
|
|
)
|
|
food_table_id = Column(
|
|
"food_table_id",
|
|
UUID(as_uuid=True),
|
|
ForeignKey("food_tables.id"),
|
|
nullable=False,
|
|
unique=True,
|
|
)
|
|
guest_book_id = Column("guest_book_id", UUID(as_uuid=True), ForeignKey("guest_book.id"), unique=True)
|
|
status = Column("status", Unicode(255), nullable=False)
|
|
|
|
voucher = relationship("Voucher", backref=backref("status", uselist=False))
|
|
food_table = relationship("FoodTable", backref=backref("status", uselist=False))
|
|
guest = relationship("GuestBook", backref=backref("status", uselist=False))
|
|
|
|
def __init__(self, voucher_id, food_table_id, guest_book_id, status, id_=None):
|
|
self.voucher_id = voucher_id
|
|
self.food_table_id = food_table_id
|
|
self.guest_book_id = guest_book_id
|
|
self.status = status
|
|
self.id = id_
|