51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
import uuid
|
|
|
|
from barker.models.meta import Base
|
|
from sqlalchemy import Column, DateTime, ForeignKey, Integer, text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
|
|
class Kot(Base):
|
|
__tablename__ = "kots"
|
|
|
|
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,
|
|
index=True,
|
|
)
|
|
code = Column("code", Integer, nullable=False, unique=True)
|
|
food_table_id = Column(
|
|
"food_table_id",
|
|
UUID(as_uuid=True),
|
|
ForeignKey("food_tables.id"),
|
|
nullable=False,
|
|
)
|
|
date = Column("date", DateTime, nullable=False, index=True)
|
|
user_id = Column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
|
|
|
user = relationship("User", backref="kots")
|
|
food_table = relationship("FoodTable", backref="kots")
|
|
inventories = relationship("Inventory", back_populates="kot")
|
|
|
|
def __init__(
|
|
self,
|
|
voucher_id=None,
|
|
code=None,
|
|
food_table_id=None,
|
|
date=None,
|
|
user_id=None,
|
|
id_=None,
|
|
):
|
|
self.id = id_
|
|
self.voucher_id = voucher_id
|
|
self.code = code
|
|
self.food_table_id = food_table_id
|
|
self.date = date
|
|
self.user_id = user_id
|