Importing now working
except u-product_group_modifier. It does not fit in the new scheme. Will remove in next commit so that it is added to log if needed later.
This commit is contained in:
@ -1,91 +0,0 @@
|
||||
"""devices
|
||||
|
||||
Revision ID: 00878740057e
|
||||
Revises: 8c06ac60d125
|
||||
Create Date: 2020-10-27 14:02:39.859733
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import column, table
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "00878740057e"
|
||||
down_revision = "8c06ac60d125"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"login_history",
|
||||
sa.Column("login_history_id", postgresql.UUID(as_uuid=True), 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.UniqueConstraint("user_id", "device_id", "date", name=op.f("uq_login_history_user_id")),
|
||||
)
|
||||
op.drop_table("clients")
|
||||
op.add_column("devices", sa.Column("enabled", sa.Boolean(), nullable=False))
|
||||
op.add_column("devices", sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False))
|
||||
op.alter_column("food_tables", "seats", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False)
|
||||
op.alter_column(
|
||||
"food_tables", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"menu_categories", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"modifier_categories", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False
|
||||
)
|
||||
op.alter_column("products", "sort_order", existing_type=sa.NUMERIC(), type_=sa.Integer(), existing_nullable=False)
|
||||
op.add_column("sections", sa.Column("is_fixture", sa.Boolean(), nullable=True))
|
||||
section = table("sections", column("id", postgresql.UUID(as_uuid=True)), column("is_fixture", sa.Boolean()))
|
||||
op.execute(
|
||||
section.update()
|
||||
.where(section.c.id == op.inline_literal("3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df"))
|
||||
.values({"is_fixture": op.inline_literal(True)})
|
||||
)
|
||||
op.execute(
|
||||
section.update()
|
||||
.where(section.c.id != op.inline_literal("3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df"))
|
||||
.values({"is_fixture": op.inline_literal(False)})
|
||||
)
|
||||
op.alter_column("sections", "is_fixture", nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("sections", "is_fixture")
|
||||
op.alter_column("products", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False)
|
||||
op.alter_column(
|
||||
"modifier_categories", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"menu_categories", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False
|
||||
)
|
||||
op.alter_column(
|
||||
"food_tables", "sort_order", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False
|
||||
)
|
||||
op.alter_column("food_tables", "seats", existing_type=sa.Integer(), type_=sa.NUMERIC(), existing_nullable=False)
|
||||
op.drop_column("devices", "enabled")
|
||||
op.create_table(
|
||||
"clients",
|
||||
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column("enabled", sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column("otp", sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column("creation_date", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name="pk_clients"),
|
||||
sa.UniqueConstraint("name", name="uq_clients_name"),
|
||||
)
|
||||
op.drop_table("login_history")
|
||||
# ### end Alembic commands ###
|
||||
74
barker/alembic/versions/34fe3d061c5f_devices1.py
Normal file
74
barker/alembic/versions/34fe3d061c5f_devices1.py
Normal file
@ -0,0 +1,74 @@
|
||||
"""devices1
|
||||
|
||||
Revision ID: 34fe3d061c5f
|
||||
Revises: 8c06ac60d125
|
||||
Create Date: 2020-10-27 19:38:48.445908
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import column, select, table
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
revision = "34fe3d061c5f"
|
||||
down_revision = "8c06ac60d125"
|
||||
branch_labels = None
|
||||
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))
|
||||
)
|
||||
sale_category = table("sale_categories", column("id", postgresql.UUID()), column("name", sa.Unicode(length=255)))
|
||||
op.execute(
|
||||
product.update(
|
||||
values={
|
||||
"sale_category_id": select([sale_category.c.id]).where(
|
||||
product.c.sale_category_name == sale_category.c.name
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
section_printer = table(
|
||||
"section_printers",
|
||||
column("section_id", postgresql.UUID()),
|
||||
column("section_name", sa.Unicode(length=255)),
|
||||
column("printer_id", postgresql.UUID()),
|
||||
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)))
|
||||
op.execute(
|
||||
section_printer.update(
|
||||
values={"section_id": select([section.c.id]).where(section_printer.c.section_name == section.c.name)}
|
||||
)
|
||||
)
|
||||
op.execute(
|
||||
section_printer.update(
|
||||
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.drop_column("section_name")
|
||||
batch_op.alter_column("printer_id", nullable=True)
|
||||
batch_op.drop_column("printer_name")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column("products", sa.Column("sale_category_name", sa.Unicode(length=255), nullable=False))
|
||||
op.drop_constraint("fk_products_sale_category_id_sale_categories", "products", type_="foreignkey")
|
||||
op.drop_column("products", "sale_category_id")
|
||||
# ### end Alembic commands ###
|
||||
@ -22,23 +22,12 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"clients",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("enabled", sa.Boolean(), nullable=False),
|
||||
sa.Column("otp", sa.Integer(), nullable=True),
|
||||
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_clients")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_clients_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"customers",
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("company", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("phone", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("address", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("phone", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("address", sa.Unicode(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_customers")),
|
||||
sa.UniqueConstraint("phone", name=op.f("uq_customers_phone")),
|
||||
)
|
||||
@ -49,7 +38,7 @@ def upgrade():
|
||||
sa.Column("discount_limit", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("is_fixture", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_menu_categories")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_menu_categories_name")),
|
||||
)
|
||||
@ -60,7 +49,7 @@ def upgrade():
|
||||
sa.Column("minimum", sa.Integer(), nullable=False),
|
||||
sa.Column("maximum", sa.Integer(), nullable=True),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_modifier_categories")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_modifier_categories_name")),
|
||||
)
|
||||
@ -92,6 +81,7 @@ def upgrade():
|
||||
"sections",
|
||||
sa.Column("id", postgresql.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")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_sections_name")),
|
||||
)
|
||||
@ -136,18 +126,31 @@ def upgrade():
|
||||
sa.Column("id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), 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")),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_devices")),
|
||||
sa.UniqueConstraint("name", name=op.f("uq_devices_name")),
|
||||
)
|
||||
op.create_table(
|
||||
"login_history",
|
||||
sa.Column("login_history_id", postgresql.UUID(as_uuid=True), 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.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("name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("seats", sa.Numeric(), nullable=False),
|
||||
sa.Column("seats", sa.Integer(), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["section_id"],
|
||||
["sections.id"],
|
||||
@ -212,8 +215,10 @@ def upgrade():
|
||||
"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=False),
|
||||
sa.Column("printer_id", postgresql.UUID(), nullable=False),
|
||||
sa.Column("section_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("section_name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("printer_id", postgresql.UUID(), nullable=True),
|
||||
sa.Column("printer_name", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("copies", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["menu_category_id"],
|
||||
@ -253,13 +258,14 @@ def upgrade():
|
||||
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=False),
|
||||
sa.Column("sale_category_id", postgresql.UUID(), 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),
|
||||
sa.Column("is_not_available", sa.Boolean(), nullable=False),
|
||||
sa.Column("quantity", sa.Numeric(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("sort_order", sa.Numeric(), nullable=False),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["menu_category_id"],
|
||||
["menu_categories.id"],
|
||||
@ -284,7 +290,7 @@ def upgrade():
|
||||
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("narration", sa.Unicode(length=1000), nullable=False),
|
||||
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),
|
||||
@ -468,7 +474,9 @@ def upgrade():
|
||||
op.execute(Permission.__table__.insert().values(id="7a04ba63-5d08-4078-9051-a6d91cce3e48", name="Section Printers"))
|
||||
op.execute(Permission.__table__.insert().values(id="d4e1d14f-f2c2-4728-9303-a0d8c74c5ea1", name="Devices"))
|
||||
op.execute(Permission.__table__.insert().values(id="5f6110ba-2d3a-41cb-9597-1157774f10cb", name="Add Devices"))
|
||||
op.execute(Section.__table__.insert().values(id="3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df", name="Main"))
|
||||
op.execute(
|
||||
Section.__table__.insert().values(id="3f13f6e7-dc76-4fca-8fdb-b2bbf29b35df", name="Main", is_fixture=True)
|
||||
)
|
||||
|
||||
op.execute(
|
||||
ModifierCategory.__table__.insert().values(
|
||||
@ -594,7 +602,6 @@ def upgrade():
|
||||
op.execute(
|
||||
Customer.__table__.insert().values(
|
||||
id="2c716f4b-0736-429a-ad51-610d7c47cb5e",
|
||||
company="",
|
||||
name="Cash",
|
||||
phone="",
|
||||
address="",
|
||||
|
||||
Reference in New Issue
Block a user