Initial setup for temporal products table.
Updated the model and the data import. Now for all the routers and then update products
This commit is contained in:
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import column, select, table
|
||||
from sqlalchemy import column, func, select, table, text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
@ -23,9 +23,13 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
product = table(
|
||||
"products", column("sale_category_id", postgresql.UUID()), column("sale_category_name", sa.Unicode(length=255))
|
||||
"products",
|
||||
column("sale_category_id", postgresql.UUID(as_uuid=True)),
|
||||
column("sale_category_name", sa.Unicode(length=255)),
|
||||
)
|
||||
sale_category = table(
|
||||
"sale_categories", column("id", postgresql.UUID(as_uuid=True)), column("name", sa.Unicode(length=255))
|
||||
)
|
||||
sale_category = table("sale_categories", column("id", postgresql.UUID()), column("name", sa.Unicode(length=255)))
|
||||
op.execute(
|
||||
product.update(
|
||||
values={
|
||||
@ -38,13 +42,13 @@ def upgrade():
|
||||
|
||||
section_printer = table(
|
||||
"section_printers",
|
||||
column("section_id", postgresql.UUID()),
|
||||
column("section_id", postgresql.UUID(as_uuid=True)),
|
||||
column("section_name", sa.Unicode(length=255)),
|
||||
column("printer_id", postgresql.UUID()),
|
||||
column("printer_id", postgresql.UUID(as_uuid=True)),
|
||||
column("printer_name", sa.Unicode(length=255)),
|
||||
)
|
||||
section = table("sections", column("id", postgresql.UUID()), column("name", sa.Unicode(length=255)))
|
||||
printer = table("printers", column("id", postgresql.UUID()), column("name", sa.Unicode(length=255)))
|
||||
section = table("sections", column("id", postgresql.UUID(as_uuid=True)), column("name", sa.Unicode(length=255)))
|
||||
printer = table("printers", column("id", postgresql.UUID(as_uuid=True)), column("name", sa.Unicode(length=255)))
|
||||
op.execute(
|
||||
section_printer.update(
|
||||
values={"section_id": select([section.c.id]).where(section_printer.c.section_name == section.c.name)}
|
||||
@ -55,14 +59,80 @@ def upgrade():
|
||||
values={"printer_id": select([printer.c.id]).where(section_printer.c.printer_name == printer.c.name)}
|
||||
)
|
||||
)
|
||||
with op.batch_alter_table("products") as batch_op:
|
||||
batch_op.alter_column("sale_category_id", nullable=True)
|
||||
batch_op.drop_column("sale_category_name")
|
||||
with op.batch_alter_table("section_printers") as batch_op:
|
||||
batch_op.alter_column("section_id", nullable=True)
|
||||
batch_op.alter_column("section_id", nullable=False)
|
||||
batch_op.drop_column("section_name")
|
||||
batch_op.alter_column("printer_id", nullable=True)
|
||||
batch_op.alter_column("printer_id", nullable=False)
|
||||
batch_op.drop_column("printer_name")
|
||||
|
||||
with op.batch_alter_table("products") as batch_op:
|
||||
batch_op.alter_column("sale_category_id", nullable=False)
|
||||
batch_op.drop_column("sale_category_name")
|
||||
|
||||
# Migration to temporal products
|
||||
op.rename_table("products", "product_histories")
|
||||
with op.batch_alter_table("product_histories") as batch_op:
|
||||
batch_op.add_column(sa.Column("valid_from", sa.Date(), nullable=True))
|
||||
batch_op.add_column(sa.Column("valid_till", sa.Date(), nullable=True))
|
||||
batch_op.drop_column("is_active")
|
||||
|
||||
op.create_table(
|
||||
"product_versions",
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("version_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["version_id"], ["product_histories.id"], name=op.f("fk_product_versions_version_id_product_histories")
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_product_versions")),
|
||||
sa.UniqueConstraint("id", "version_id", name=op.f("uq_product_versions_id")),
|
||||
)
|
||||
op.drop_constraint("fk_inventories_product_id_products", "inventories", type_="foreignkey")
|
||||
op.create_foreign_key(
|
||||
op.f("fk_inventories_product_id_product_versions"), "inventories", "product_versions", ["product_id"], ["id"]
|
||||
)
|
||||
|
||||
pv = table(
|
||||
"product_versions",
|
||||
column("id", postgresql.UUID(as_uuid=True)),
|
||||
column("version_id", postgresql.UUID(as_uuid=True)),
|
||||
)
|
||||
|
||||
prod = table(
|
||||
"product_histories",
|
||||
column("id", postgresql.UUID(as_uuid=True)),
|
||||
column("name", postgresql.UUID(as_uuid=True)),
|
||||
column("units", postgresql.UUID(as_uuid=True)),
|
||||
column("valid_from", sa.Date()),
|
||||
column("valid_till", sa.Date()),
|
||||
)
|
||||
op.execute(pv.insert().from_select([pv.c.id, pv.c.version_id], select([prod.c.id, prod.c.id.label("vid")])))
|
||||
|
||||
op.alter_column("modifier_categories_products", "modifier_categories_id", new_column_name="modifier_category_id")
|
||||
op.drop_constraint("uq_modifier_categories_products_product_id", "modifier_categories_products", type_="unique")
|
||||
op.create_unique_constraint(
|
||||
op.f("uq_modifier_categories_products_product_id"),
|
||||
"modifier_categories_products",
|
||||
["product_id", "modifier_category_id"],
|
||||
)
|
||||
|
||||
op.drop_constraint(
|
||||
"fk_modifier_categories_products_product_id_products", "modifier_categories_products", type_="foreignkey"
|
||||
)
|
||||
op.create_foreign_key(
|
||||
op.f("fk_modifier_categories_products_product_id_product_versions"),
|
||||
"modifier_categories_products",
|
||||
"product_versions",
|
||||
["product_id"],
|
||||
["id"],
|
||||
)
|
||||
op.create_exclude_constraint(
|
||||
"uq_product_histories_name",
|
||||
"product_histories",
|
||||
(prod.c.name, "="),
|
||||
(prod.c.units, "="),
|
||||
(func.daterange(prod.c.valid_from, prod.c.valid_till, text("'[]'")), "&&"),
|
||||
)
|
||||
op.drop_constraint("uq_products_name", "product_histories", type_="unique")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"customers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("phone", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("address", sa.Unicode(length=255), nullable=True),
|
||||
@ -33,7 +33,7 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"menu_categories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("discount_limit", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
@ -44,7 +44,7 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"modifier_categories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("minimum", sa.Integer(), nullable=False),
|
||||
sa.Column("maximum", sa.Integer(), nullable=True),
|
||||
@ -55,14 +55,14 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"permissions",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_permissions")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_permissions_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"printers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("address", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("cut_code", sa.Unicode(length=255), nullable=False),
|
||||
@ -72,14 +72,14 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"roles",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_roles")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_roles_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"sections",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("is_fixture", sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_sections")),
|
||||
@ -87,7 +87,7 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"settings",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("data", sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_settings")),
|
||||
@ -105,7 +105,7 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"taxes",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("rate", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_fixture", sa.Boolean(), nullable=False),
|
||||
@ -114,7 +114,7 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"users",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("password", sa.Unicode(length=60), nullable=False),
|
||||
sa.Column("locked_out", sa.Boolean(), nullable=False),
|
||||
@ -123,9 +123,9 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"devices",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("enabled", sa.Boolean(), nullable=False),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["section_id"], ["sections.id"], name=op.f("fk_devices_section_id_sections")),
|
||||
@ -134,21 +134,21 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"login_history",
|
||||
sa.Column("login_history_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("device_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["device_id"], ["devices.id"], name=op.f("fk_login_history_device_id_devices")),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_login_history_user_id_users")),
|
||||
sa.PrimaryKeyConstraint("login_history_id", name=op.f("pk_login_history")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_login_history")),
|
||||
sa.UniqueConstraint("user_id", "device_id", "date", name=op.f("uq_login_history_user_id")),
|
||||
)
|
||||
op.create_table(
|
||||
"food_tables",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("seats", sa.Integer(), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
@ -161,8 +161,8 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"guest_book",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("customer_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("customer_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("pax", sa.Numeric(), nullable=False),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
@ -174,12 +174,12 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"modifiers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("show_in_bill", sa.Boolean(), nullable=False),
|
||||
sa.Column("price", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("modifier_category_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("modifier_category_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["modifier_category_id"],
|
||||
["modifier_categories.id"],
|
||||
@ -190,9 +190,9 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"role_permissions",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("permission_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("role_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("permission_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("role_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["permission_id"],
|
||||
["permissions.id"],
|
||||
@ -204,20 +204,20 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"sale_categories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("tax_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("tax_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["tax_id"], ["taxes.id"], name=op.f("fk_sale_categories_tax_id_taxes")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_sale_categories")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_sale_categories_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"section_printers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("menu_category_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("menu_category_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("section_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("section_name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("printer_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("printer_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("printer_name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("copies", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
@ -244,9 +244,9 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"user_roles",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("role_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("role_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["role_id"], ["roles.id"], name=op.f("fk_user_roles_role_id_roles")),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_user_roles_user_id_users")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_user_roles")),
|
||||
@ -254,11 +254,11 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"products",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("units", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("menu_category_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("sale_category_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("menu_category_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("sale_category_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("sale_category_name", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("price", sa.Numeric(), nullable=False),
|
||||
sa.Column("has_happy_hour", sa.Boolean(), nullable=False),
|
||||
@ -281,19 +281,19 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"vouchers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("date", sa.DateTime(), nullable=False),
|
||||
sa.Column("pax", sa.Numeric(), nullable=False),
|
||||
sa.Column("bill_id", sa.Numeric(), nullable=True),
|
||||
sa.Column("kot_id", sa.Numeric(), nullable=False),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("last_edit_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("customer_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("food_table_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("customer_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("narration", sa.Unicode(length=1000), nullable=True),
|
||||
sa.Column("reason", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("voucher_type", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["customer_id"],
|
||||
["customers.id"],
|
||||
@ -312,12 +312,12 @@ def upgrade():
|
||||
op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False)
|
||||
op.create_table(
|
||||
"kots",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("code", sa.Numeric(), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("date", sa.DateTime(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["food_table_id"],
|
||||
["food_tables.id"],
|
||||
@ -332,9 +332,9 @@ def upgrade():
|
||||
op.create_index(op.f("ix_kots_voucher_id"), "kots", ["voucher_id"], unique=False)
|
||||
op.create_table(
|
||||
"modifier_categories_products",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("product_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("modifier_categories_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("product_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("modifier_categories_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["modifier_categories_id"],
|
||||
["modifier_categories.id"],
|
||||
@ -354,10 +354,10 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"overview",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("guest_book_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("food_table_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("guest_book_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("status", sa.Unicode(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["food_table_id"],
|
||||
@ -381,10 +381,10 @@ def upgrade():
|
||||
)
|
||||
op.create_table(
|
||||
"reprints",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("date", sa.DateTime(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_reprints_user_id_users")),
|
||||
sa.ForeignKeyConstraint(
|
||||
["voucher_id"],
|
||||
@ -397,8 +397,8 @@ def upgrade():
|
||||
op.create_index(op.f("ix_reprints_voucher_id"), "reprints", ["voucher_id"], unique=False)
|
||||
op.create_table(
|
||||
"settlements",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("voucher_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("settled", sa.Integer(), nullable=False),
|
||||
sa.Column("amount", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
@ -417,14 +417,14 @@ def upgrade():
|
||||
op.create_index(op.f("ix_settlements_voucher_id"), "settlements", ["voucher_id"], unique=False)
|
||||
op.create_table(
|
||||
"inventories",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("kot_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("product_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("kot_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("product_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("quantity", sa.Numeric(), nullable=True),
|
||||
sa.Column("price", sa.Numeric(), nullable=True),
|
||||
sa.Column("is_happy_hour", sa.Boolean(), nullable=False),
|
||||
sa.Column("tax_rate", sa.Numeric(), nullable=True),
|
||||
sa.Column("tax_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("tax_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("discount", sa.Numeric(), nullable=True),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["kot_id"], ["kots.id"], name=op.f("fk_inventories_kot_id_kots")),
|
||||
@ -446,9 +446,9 @@ def upgrade():
|
||||
op.create_index(op.f("ix_inventories_kot_id"), "inventories", ["kot_id"], unique=False)
|
||||
op.create_table(
|
||||
"inventory_modifiers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("inventory_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("modifier_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
|
||||
sa.Column("inventory_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("modifier_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column("price", sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["inventory_id"],
|
||||
|
||||
Reference in New Issue
Block a user