176 lines
9.7 KiB
Python
176 lines
9.7 KiB
Python
"""Recipe upgrade
|
|
|
|
Revision ID: a1372ed99c45
|
|
Revises: 185c674cc392
|
|
Create Date: 2023-03-31 05:03:40.408240
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
from sqlalchemy import func
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "a1372ed99c45"
|
|
down_revision = "185c674cc392"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"tags",
|
|
sa.Column("id", sa.Uuid(), nullable=False),
|
|
sa.Column("name", sa.Unicode(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_tags")),
|
|
sa.UniqueConstraint("name", name=op.f("uq_tags_name")),
|
|
)
|
|
op.create_table(
|
|
"recipe_tags",
|
|
sa.Column("id", sa.Uuid(), nullable=False),
|
|
sa.Column("recipe_id", sa.Uuid(), nullable=False),
|
|
sa.Column("tag_id", sa.Uuid(), nullable=False),
|
|
sa.ForeignKeyConstraint(["recipe_id"], ["recipes.id"], name=op.f("fk_recipe_tags_recipe_id_recipes")),
|
|
sa.ForeignKeyConstraint(["tag_id"], ["tags.id"], name=op.f("fk_recipe_tags_tag_id_tags")),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_recipe_tags")),
|
|
sa.UniqueConstraint("recipe_id", "tag_id", name=op.f("uq_recipe_tags_recipe_id")),
|
|
)
|
|
op.alter_column("attendances", "employee_id", existing_type=sa.UUID(), nullable=False)
|
|
op.alter_column("attendances", "attendance_type", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("attendances", "amount", existing_type=sa.NUMERIC(precision=5, scale=2), nullable=False)
|
|
op.alter_column("attendances", "creation_date", existing_type=postgresql.TIMESTAMP(), nullable=False)
|
|
op.alter_column("attendances", "user_id", existing_type=sa.UUID(), nullable=False)
|
|
op.alter_column("attendances", "is_valid", existing_type=sa.BOOLEAN(), nullable=False)
|
|
op.alter_column("cost_centres", "name", existing_type=sa.VARCHAR(length=255), nullable=False)
|
|
op.alter_column("employee_benefit", "gross_salary", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("employee_benefit", "days_worked", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("employee_benefit", "esi_employee", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("employee_benefit", "pf_employee", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("employee_benefit", "esi_employer", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("employee_benefit", "pf_employer", existing_type=sa.INTEGER(), nullable=False)
|
|
op.alter_column("fingerprints", "employee_id", existing_type=sa.UUID(), nullable=False)
|
|
op.alter_column("fingerprints", "date", existing_type=postgresql.TIMESTAMP(), nullable=False)
|
|
op.alter_column("permissions", "name", existing_type=sa.VARCHAR(length=255), nullable=False)
|
|
op.alter_column("product_groups", "name", existing_type=sa.VARCHAR(length=255), nullable=False)
|
|
op.add_column("products", sa.Column("description", sa.Text(), nullable=True))
|
|
op.alter_column("products", "code", existing_type=sa.INTEGER(), nullable=False)
|
|
op.add_column("recipes", sa.Column("date", sa.Date(), nullable=False, server_default=func.now()))
|
|
op.add_column("recipes", sa.Column("source", sa.Text(), nullable=False, server_default=""))
|
|
op.add_column("recipes", sa.Column("instructions", sa.Text(), nullable=False, server_default=""))
|
|
op.add_column("recipes", sa.Column("garnishing", sa.Text(), nullable=False, server_default=""))
|
|
op.add_column("recipes", sa.Column("plating", sa.Text(), nullable=False, server_default=""))
|
|
op.drop_constraint(op.f("uq_recipes_sku_id"), "recipes", type_="unique")
|
|
op.alter_column("recipes", "notes", existing_type=sa.VARCHAR(length=255), type=sa.Text(), nullable=False)
|
|
op.create_unique_constraint(op.f("uq_recipes_sku_id"), "recipes", ["sku_id", "date"])
|
|
op.create_index(op.f("ix_recipes_date"), "recipes", ["date"], unique=False)
|
|
op.drop_constraint("fk_recipes_period_id_periods", "recipes", type_="foreignkey")
|
|
op.drop_column("recipes", "period_id")
|
|
op.drop_column("recipes", "sale_price")
|
|
op.drop_column("recipes", "cost_price")
|
|
op.add_column("recipe_items", sa.Column("description", sa.Text(), nullable=False, server_default=""))
|
|
op.drop_column("recipe_items", "price")
|
|
op.alter_column("role_permissions", "permission_id", existing_type=sa.UUID(), nullable=False)
|
|
op.alter_column("role_permissions", "role_id", existing_type=sa.UUID(), nullable=False)
|
|
op.create_unique_constraint(
|
|
op.f("uq_role_permissions_permission_id"), "role_permissions", ["permission_id", "role_id"]
|
|
)
|
|
op.alter_column("roles", "name", existing_type=sa.VARCHAR(length=255), nullable=False)
|
|
op.alter_column("settings", "data", existing_type=postgresql.BYTEA(), nullable=False)
|
|
op.alter_column("user_roles", "user_id", existing_type=sa.UUID(), nullable=False)
|
|
op.alter_column("user_roles", "role_id", existing_type=sa.UUID(), nullable=False)
|
|
op.create_unique_constraint(op.f("uq_user_roles_user_id"), "user_roles", ["user_id", "role_id"])
|
|
op.alter_column("users", "username", existing_type=sa.VARCHAR(length=255), nullable=False)
|
|
op.alter_column("users", "password", existing_type=sa.VARCHAR(length=60), nullable=False)
|
|
op.alter_column("users", "disabled", existing_type=sa.BOOLEAN(), nullable=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.alter_column(
|
|
"vouchers",
|
|
"voucher_type",
|
|
existing_type=sa.Enum(
|
|
"JOURNAL",
|
|
"PURCHASE",
|
|
"ISSUE",
|
|
"PAYMENT",
|
|
"RECEIPT",
|
|
"PURCHASE_RETURN",
|
|
"OPENING_ACCOUNTS",
|
|
"OPENING_BATCHES",
|
|
"CLOSING_STOCK",
|
|
"OPENING_BALANCE",
|
|
"CLOSING_BALANCE",
|
|
"EMPLOYEE_BENEFIT",
|
|
"INCENTIVE",
|
|
name="vouchertype",
|
|
),
|
|
type_=postgresql.ENUM(
|
|
"JOURNAL",
|
|
"PURCHASE",
|
|
"ISSUE",
|
|
"PAYMENT",
|
|
"RECEIPT",
|
|
"PURCHASE_RETURN",
|
|
"OPENING_ACCOUNTS",
|
|
"OPENING_BATCHES",
|
|
"CLOSING_STOCK",
|
|
"OPENING_BALANCE",
|
|
"CLOSING_BALANCE",
|
|
"EMPLOYEE_BENEFIT",
|
|
"INCENTIVE",
|
|
name="voucher_type",
|
|
),
|
|
existing_nullable=False,
|
|
)
|
|
op.alter_column("users", "disabled", existing_type=sa.BOOLEAN(), nullable=True)
|
|
op.alter_column("users", "username", existing_type=sa.VARCHAR(length=255), nullable=True)
|
|
op.drop_constraint(op.f("uq_user_roles_user_id"), "user_roles", type_="unique")
|
|
op.alter_column("user_roles", "role_id", existing_type=sa.UUID(), nullable=True)
|
|
op.alter_column("user_roles", "user_id", existing_type=sa.UUID(), nullable=True)
|
|
op.alter_column(
|
|
"settings",
|
|
"setting_type",
|
|
existing_type=sa.Enum("VOUCHER_LOCK", "MAINTENANCE_MODE", name="settingtype"),
|
|
type_=postgresql.ENUM("VOUCHER_LOCK", name="setting_type"),
|
|
existing_nullable=False,
|
|
)
|
|
op.alter_column("settings", "data", existing_type=postgresql.BYTEA(), nullable=True)
|
|
op.alter_column("roles", "name", existing_type=sa.VARCHAR(length=255), nullable=True)
|
|
op.drop_constraint(op.f("uq_role_permissions_permission_id"), "role_permissions", type_="unique")
|
|
op.alter_column("role_permissions", "role_id", existing_type=sa.UUID(), nullable=True)
|
|
op.alter_column("role_permissions", "permission_id", existing_type=sa.UUID(), nullable=True)
|
|
op.drop_index(op.f("ix_recipes_date"), table_name="recipes")
|
|
op.alter_column("recipes", "notes", existing_type=sa.VARCHAR(length=255), nullable=True)
|
|
op.drop_column("recipes", "plating")
|
|
op.drop_column("recipes", "garnishing")
|
|
op.drop_column("recipes", "instructions")
|
|
op.drop_column("recipes", "source")
|
|
op.drop_column("recipes", "date")
|
|
op.alter_column("products", "code", existing_type=sa.INTEGER(), nullable=True)
|
|
op.drop_column("products", "description")
|
|
op.alter_column("product_groups", "name", existing_type=sa.VARCHAR(length=255), nullable=True)
|
|
op.alter_column("permissions", "name", existing_type=sa.VARCHAR(length=255), nullable=True)
|
|
op.alter_column("fingerprints", "date", existing_type=postgresql.TIMESTAMP(), nullable=True)
|
|
op.alter_column("fingerprints", "employee_id", existing_type=sa.UUID(), nullable=True)
|
|
op.alter_column("employee_benefit", "pf_employer", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("employee_benefit", "esi_employer", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("employee_benefit", "pf_employee", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("employee_benefit", "esi_employee", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("employee_benefit", "days_worked", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("employee_benefit", "gross_salary", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("cost_centres", "name", existing_type=sa.VARCHAR(length=255), nullable=True)
|
|
op.alter_column("attendances", "is_valid", existing_type=sa.BOOLEAN(), nullable=True)
|
|
op.alter_column("attendances", "user_id", existing_type=sa.UUID(), nullable=True)
|
|
op.alter_column("attendances", "creation_date", existing_type=postgresql.TIMESTAMP(), nullable=True)
|
|
op.alter_column("attendances", "amount", existing_type=sa.NUMERIC(precision=5, scale=2), nullable=True)
|
|
op.alter_column("attendances", "attendance_type", existing_type=sa.INTEGER(), nullable=True)
|
|
op.alter_column("attendances", "employee_id", existing_type=sa.UUID(), nullable=True)
|
|
op.drop_table("recipe_tags")
|
|
op.drop_table("tags")
|
|
# ### end Alembic commands ###
|