43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import uuid
|
|
|
|
from barker.models.meta import Base
|
|
from sqlalchemy import Boolean, Column, ForeignKey, Numeric, Unicode, text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
|
|
class Modifier(Base):
|
|
__tablename__ = "modifiers"
|
|
|
|
id = Column(
|
|
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), default=uuid.uuid4
|
|
)
|
|
name = Column("name", Unicode(255), nullable=False, unique=True)
|
|
show_in_bill = Column("show_in_bill", Boolean, nullable=False)
|
|
price = Column("price", Numeric(precision=15, scale=2), nullable=False)
|
|
is_active = Column("is_active", Boolean, nullable=False)
|
|
modifier_category_id = Column(
|
|
"modifier_category_id",
|
|
UUID(as_uuid=True),
|
|
ForeignKey("modifier_categories.id"),
|
|
nullable=False,
|
|
)
|
|
|
|
modifier_category = relationship("ModifierCategory", backref="modifiers")
|
|
|
|
def __init__(
|
|
self,
|
|
name=None,
|
|
show_in_bill=None,
|
|
price=None,
|
|
modifier_category_id=None,
|
|
is_active=True,
|
|
id_=None,
|
|
):
|
|
self.id = id_
|
|
self.name = name
|
|
self.show_in_bill = show_in_bill
|
|
self.price = price
|
|
self.modifier_category_id = modifier_category_id
|
|
self.is_active = is_active
|