Blacked all lines with -l 120

This commit is contained in:
2020-05-31 14:41:11 +05:30
parent 1f7ca329bc
commit 1c2c98e7b5
64 changed files with 924 additions and 1727 deletions

View File

@ -7,13 +7,14 @@ from alembic import context
from brewman.core.config import settings
logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(settings.ALEMBIC_LOG_LEVEL)
logging.getLogger('alembic').setLevel(settings.ALEMBIC_LOG_LEVEL)
logging.getLogger("sqlalchemy.engine").setLevel(settings.ALEMBIC_LOG_LEVEL)
logging.getLogger("alembic").setLevel(settings.ALEMBIC_LOG_LEVEL)
# Interpret the config file for Python logging.
# This line sets up loggers basically.
from brewman.models.auth import User # noqa
from brewman.models.auth import User # noqa
target_metadata = User.metadata
# other values from the config, defined by the needs of env.py,
@ -40,7 +41,7 @@ def run_migrations_offline():
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
compare_type=True
compare_type=True,
)
with context.begin_transaction():
@ -54,13 +55,10 @@ def run_migrations_online():
and associate a connection with the context.
"""
connectable = create_engine(settings.SQLALCHEMY_DATABASE_URI, poolclass=pool.NullPool, )
connectable = create_engine(settings.SQLALCHEMY_DATABASE_URI, poolclass=pool.NullPool,)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata,
compare_type=True
)
context.configure(connection=connection, target_metadata=target_metadata, compare_type=True)
with context.begin_transaction():
context.run_migrations()

View File

@ -10,7 +10,7 @@ import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '0bf3d70ee7de'
revision = "0bf3d70ee7de"
down_revision = None
branch_labels = None
depends_on = None
@ -18,297 +18,347 @@ depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('auth_clients',
sa.Column('client_id', postgresql.UUID(), nullable=False),
sa.Column('code', 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('client_id', name=op.f('pk_auth_clients')),
sa.UniqueConstraint('code', name=op.f('uq_auth_clients_code')),
sa.UniqueConstraint('name', name=op.f('uq_auth_clients_name'))
op.create_table(
"auth_clients",
sa.Column("client_id", postgresql.UUID(), nullable=False),
sa.Column("code", 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("client_id", name=op.f("pk_auth_clients")),
sa.UniqueConstraint("code", name=op.f("uq_auth_clients_code")),
sa.UniqueConstraint("name", name=op.f("uq_auth_clients_name")),
)
op.create_table('auth_groups',
sa.Column('GroupID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint('GroupID', name=op.f('pk_auth_groups')),
sa.UniqueConstraint('Name', name=op.f('uq_auth_groups_Name'))
op.create_table(
"auth_groups",
sa.Column("GroupID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint("GroupID", name=op.f("pk_auth_groups")),
sa.UniqueConstraint("Name", name=op.f("uq_auth_groups_Name")),
)
op.create_table('auth_roles',
sa.Column('RoleID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint('RoleID', name=op.f('pk_auth_roles')),
sa.UniqueConstraint('Name', name=op.f('uq_auth_roles_Name'))
op.create_table(
"auth_roles",
sa.Column("RoleID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint("RoleID", name=op.f("pk_auth_roles")),
sa.UniqueConstraint("Name", name=op.f("uq_auth_roles_Name")),
)
op.create_table('auth_users',
sa.Column('UserID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.Unicode(length=255), nullable=True),
sa.Column('Password', sa.Unicode(length=60), nullable=True),
sa.Column('LockedOut', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('UserID', name=op.f('pk_auth_users')),
sa.UniqueConstraint('Name', name=op.f('uq_auth_users_Name'))
op.create_table(
"auth_users",
sa.Column("UserID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.Unicode(length=255), nullable=True),
sa.Column("Password", sa.Unicode(length=60), nullable=True),
sa.Column("LockedOut", sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint("UserID", name=op.f("pk_auth_users")),
sa.UniqueConstraint("Name", name=op.f("uq_auth_users_Name")),
)
op.create_table('cost_centres',
sa.Column('CostCentreID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.Unicode(length=255), nullable=True),
sa.Column('IsFixture', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('CostCentreID', name=op.f('pk_cost_centres')),
sa.UniqueConstraint('Name', name=op.f('uq_cost_centres_Name'))
op.create_table(
"cost_centres",
sa.Column("CostCentreID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.Unicode(length=255), nullable=True),
sa.Column("IsFixture", sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint("CostCentreID", name=op.f("pk_cost_centres")),
sa.UniqueConstraint("Name", name=op.f("uq_cost_centres_Name")),
)
op.create_table('images',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('resource_id', postgresql.UUID(), nullable=False),
sa.Column('resource_type', sa.Unicode(length=255), nullable=False),
sa.Column('image', postgresql.BYTEA(), nullable=False),
sa.Column('thumbnail', postgresql.BYTEA(), nullable=False),
sa.Column('creation_date', sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_images'))
op.create_table(
"images",
sa.Column("id", postgresql.UUID(), nullable=False),
sa.Column("resource_id", postgresql.UUID(), nullable=False),
sa.Column("resource_type", sa.Unicode(length=255), nullable=False),
sa.Column("image", postgresql.BYTEA(), nullable=False),
sa.Column("thumbnail", postgresql.BYTEA(), nullable=False),
sa.Column("creation_date", sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_images")),
)
op.create_table('product_groups',
sa.Column('ProductGroupID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.Unicode(length=255), nullable=True),
sa.Column('IsFixture', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('ProductGroupID', name=op.f('pk_product_groups')),
sa.UniqueConstraint('Name', name=op.f('uq_product_groups_Name'))
op.create_table(
"product_groups",
sa.Column("ProductGroupID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.Unicode(length=255), nullable=True),
sa.Column("IsFixture", sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint("ProductGroupID", name=op.f("pk_product_groups")),
sa.UniqueConstraint("Name", name=op.f("uq_product_groups_Name")),
)
op.create_table('settings',
sa.Column('SettingID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.Unicode(length=255), nullable=False),
sa.Column('Data', sa.PickleType(), nullable=True),
sa.PrimaryKeyConstraint('SettingID', name=op.f('pk_settings')),
sa.UniqueConstraint('Name', name=op.f('uq_settings_Name'))
op.create_table(
"settings",
sa.Column("SettingID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.Unicode(length=255), nullable=False),
sa.Column("Data", sa.PickleType(), nullable=True),
sa.PrimaryKeyConstraint("SettingID", name=op.f("pk_settings")),
sa.UniqueConstraint("Name", name=op.f("uq_settings_Name")),
)
op.create_table('accounts',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('code', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=255), nullable=False),
sa.Column('type', sa.Integer(), nullable=False),
sa.Column('account_type', sa.Unicode(length=50), nullable=False),
sa.Column('is_starred', sa.Boolean(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('is_reconcilable', sa.Boolean(), nullable=False),
sa.Column('cost_centre_id', postgresql.UUID(), nullable=False),
sa.Column('is_fixture', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['cost_centre_id'], ['cost_centres.CostCentreID'], name=op.f('fk_accounts_cost_centre_id_cost_centres')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_accounts')),
sa.UniqueConstraint('name', name=op.f('uq_accounts_name'))
op.create_table(
"accounts",
sa.Column("id", postgresql.UUID(), nullable=False),
sa.Column("code", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.Column("type", sa.Integer(), nullable=False),
sa.Column("account_type", sa.Unicode(length=50), nullable=False),
sa.Column("is_starred", sa.Boolean(), nullable=False),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("is_reconcilable", sa.Boolean(), nullable=False),
sa.Column("cost_centre_id", postgresql.UUID(), nullable=False),
sa.Column("is_fixture", sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(
["cost_centre_id"], ["cost_centres.CostCentreID"], name=op.f("fk_accounts_cost_centre_id_cost_centres"),
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_accounts")),
sa.UniqueConstraint("name", name=op.f("uq_accounts_name")),
)
op.create_table('auth_login_history',
sa.Column('login_history_id', postgresql.UUID(), nullable=False),
sa.Column('user_id', postgresql.UUID(), nullable=False),
sa.Column('client_id', postgresql.UUID(), nullable=False),
sa.Column('date', sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(['client_id'], ['auth_clients.client_id'], name=op.f('fk_auth_login_history_client_id_auth_clients')),
sa.ForeignKeyConstraint(['user_id'], ['auth_users.UserID'], name=op.f('fk_auth_login_history_user_id_auth_users')),
sa.PrimaryKeyConstraint('login_history_id', name=op.f('pk_auth_login_history')),
sa.UniqueConstraint('user_id', 'client_id', 'date', name=op.f('uq_auth_login_history_user_id'))
op.create_table(
"auth_login_history",
sa.Column("login_history_id", postgresql.UUID(), nullable=False),
sa.Column("user_id", postgresql.UUID(), nullable=False),
sa.Column("client_id", postgresql.UUID(), nullable=False),
sa.Column("date", sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(
["client_id"], ["auth_clients.client_id"], name=op.f("fk_auth_login_history_client_id_auth_clients"),
),
sa.ForeignKeyConstraint(
["user_id"], ["auth_users.UserID"], name=op.f("fk_auth_login_history_user_id_auth_users"),
),
sa.PrimaryKeyConstraint("login_history_id", name=op.f("pk_auth_login_history")),
sa.UniqueConstraint("user_id", "client_id", "date", name=op.f("uq_auth_login_history_user_id")),
)
op.create_table('auth_rolegroups',
sa.Column('RoleGroupID', postgresql.UUID(), nullable=False),
sa.Column('RoleID', postgresql.UUID(), nullable=True),
sa.Column('GroupID', postgresql.UUID(), nullable=True),
sa.ForeignKeyConstraint(['GroupID'], ['auth_groups.GroupID'], name=op.f('fk_auth_rolegroups_GroupID_auth_groups')),
sa.ForeignKeyConstraint(['RoleID'], ['auth_roles.RoleID'], name=op.f('fk_auth_rolegroups_RoleID_auth_roles')),
sa.PrimaryKeyConstraint('RoleGroupID', name=op.f('pk_auth_rolegroups'))
op.create_table(
"auth_rolegroups",
sa.Column("RoleGroupID", postgresql.UUID(), nullable=False),
sa.Column("RoleID", postgresql.UUID(), nullable=True),
sa.Column("GroupID", postgresql.UUID(), nullable=True),
sa.ForeignKeyConstraint(
["GroupID"], ["auth_groups.GroupID"], name=op.f("fk_auth_rolegroups_GroupID_auth_groups"),
),
sa.ForeignKeyConstraint(["RoleID"], ["auth_roles.RoleID"], name=op.f("fk_auth_rolegroups_RoleID_auth_roles"),),
sa.PrimaryKeyConstraint("RoleGroupID", name=op.f("pk_auth_rolegroups")),
)
op.create_table('auth_usergroups',
sa.Column('UserGroupID', postgresql.UUID(), nullable=False),
sa.Column('UserID', postgresql.UUID(), nullable=True),
sa.Column('GroupID', postgresql.UUID(), nullable=True),
sa.ForeignKeyConstraint(['GroupID'], ['auth_groups.GroupID'], name=op.f('fk_auth_usergroups_GroupID_auth_groups')),
sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name=op.f('fk_auth_usergroups_UserID_auth_users')),
sa.PrimaryKeyConstraint('UserGroupID', name=op.f('pk_auth_usergroups'))
op.create_table(
"auth_usergroups",
sa.Column("UserGroupID", postgresql.UUID(), nullable=False),
sa.Column("UserID", postgresql.UUID(), nullable=True),
sa.Column("GroupID", postgresql.UUID(), nullable=True),
sa.ForeignKeyConstraint(
["GroupID"], ["auth_groups.GroupID"], name=op.f("fk_auth_usergroups_GroupID_auth_groups"),
),
sa.ForeignKeyConstraint(["UserID"], ["auth_users.UserID"], name=op.f("fk_auth_usergroups_UserID_auth_users"),),
sa.PrimaryKeyConstraint("UserGroupID", name=op.f("pk_auth_usergroups")),
)
op.create_table('vouchers',
sa.Column('VoucherID', postgresql.UUID(), nullable=False),
sa.Column('date', sa.DateTime(), nullable=False),
sa.Column('narration', sa.Unicode(length=1000), nullable=False),
sa.Column('is_reconciled', sa.Boolean(), nullable=False),
sa.Column('reconcile_date', sa.DateTime(), nullable=False),
sa.Column('is_starred', sa.Boolean(), 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('voucher_type', sa.Integer(), nullable=False),
sa.Column('user_id', postgresql.UUID(), nullable=False),
sa.Column('is_posted', sa.Boolean(), nullable=False),
sa.Column('poster_id', postgresql.UUID(), nullable=True),
sa.ForeignKeyConstraint(['poster_id'], ['auth_users.UserID'], name=op.f('fk_vouchers_poster_id_auth_users')),
sa.ForeignKeyConstraint(['user_id'], ['auth_users.UserID'], name=op.f('fk_vouchers_user_id_auth_users')),
sa.PrimaryKeyConstraint('VoucherID', name=op.f('pk_vouchers'))
op.create_table(
"vouchers",
sa.Column("VoucherID", postgresql.UUID(), nullable=False),
sa.Column("date", sa.DateTime(), nullable=False),
sa.Column("narration", sa.Unicode(length=1000), nullable=False),
sa.Column("is_reconciled", sa.Boolean(), nullable=False),
sa.Column("reconcile_date", sa.DateTime(), nullable=False),
sa.Column("is_starred", sa.Boolean(), 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("voucher_type", sa.Integer(), nullable=False),
sa.Column("user_id", postgresql.UUID(), nullable=False),
sa.Column("is_posted", sa.Boolean(), nullable=False),
sa.Column("poster_id", postgresql.UUID(), nullable=True),
sa.ForeignKeyConstraint(["poster_id"], ["auth_users.UserID"], name=op.f("fk_vouchers_poster_id_auth_users"),),
sa.ForeignKeyConstraint(["user_id"], ["auth_users.UserID"], name=op.f("fk_vouchers_user_id_auth_users"),),
sa.PrimaryKeyConstraint("VoucherID", name=op.f("pk_vouchers")),
)
op.create_index(op.f('ix_vouchers_date'), 'vouchers', ['date'], unique=False)
op.create_table('employees',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('Designation', sa.Unicode(length=255), nullable=True),
sa.Column('Salary', sa.Integer(), nullable=True),
sa.Column('ServicePoints', sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column('JoiningDate', sa.DateTime(), nullable=True),
sa.Column('LeavingDate', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['id'], ['accounts.id'], name=op.f('fk_employees_id_accounts')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_employees'))
op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False)
op.create_table(
"employees",
sa.Column("id", postgresql.UUID(), nullable=False),
sa.Column("Designation", sa.Unicode(length=255), nullable=True),
sa.Column("Salary", sa.Integer(), nullable=True),
sa.Column("ServicePoints", sa.Numeric(precision=5, scale=2), nullable=True),
sa.Column("JoiningDate", sa.DateTime(), nullable=True),
sa.Column("LeavingDate", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(["id"], ["accounts.id"], name=op.f("fk_employees_id_accounts")),
sa.PrimaryKeyConstraint("id", name=op.f("pk_employees")),
)
op.create_table('journals',
sa.Column('JournalID', postgresql.UUID(), nullable=False),
sa.Column('Debit', sa.Integer(), nullable=True),
sa.Column('Amount', sa.Numeric(), nullable=True),
sa.Column('VoucherID', postgresql.UUID(), nullable=False),
sa.Column('account_id', postgresql.UUID(), nullable=False),
sa.Column('CostCentreID', postgresql.UUID(), nullable=False),
sa.ForeignKeyConstraint(['CostCentreID'], ['cost_centres.CostCentreID'], name=op.f('fk_journals_CostCentreID_cost_centres')),
sa.ForeignKeyConstraint(['VoucherID'], ['vouchers.VoucherID'], name=op.f('fk_journals_VoucherID_vouchers')),
sa.ForeignKeyConstraint(['account_id'], ['accounts.id'], name=op.f('fk_journals_account_id_accounts')),
sa.PrimaryKeyConstraint('JournalID', name=op.f('pk_journals'))
op.create_table(
"journals",
sa.Column("JournalID", postgresql.UUID(), nullable=False),
sa.Column("Debit", sa.Integer(), nullable=True),
sa.Column("Amount", sa.Numeric(), nullable=True),
sa.Column("VoucherID", postgresql.UUID(), nullable=False),
sa.Column("account_id", postgresql.UUID(), nullable=False),
sa.Column("CostCentreID", postgresql.UUID(), nullable=False),
sa.ForeignKeyConstraint(
["CostCentreID"], ["cost_centres.CostCentreID"], name=op.f("fk_journals_CostCentreID_cost_centres"),
),
sa.ForeignKeyConstraint(["VoucherID"], ["vouchers.VoucherID"], name=op.f("fk_journals_VoucherID_vouchers"),),
sa.ForeignKeyConstraint(["account_id"], ["accounts.id"], name=op.f("fk_journals_account_id_accounts"),),
sa.PrimaryKeyConstraint("JournalID", name=op.f("pk_journals")),
)
op.create_index(op.f('ix_journals_VoucherID'), 'journals', ['VoucherID'], unique=False)
op.create_table('products',
sa.Column('ProductID', postgresql.UUID(), nullable=False),
sa.Column('Code', sa.Integer(), nullable=True),
sa.Column('Name', sa.Unicode(length=255), nullable=False),
sa.Column('Units', sa.Unicode(length=255), nullable=False),
sa.Column('Fraction', sa.Numeric(), nullable=False),
sa.Column('FractionUnits', sa.Unicode(length=255), nullable=False),
sa.Column('ProductYield', sa.Numeric(), nullable=False),
sa.Column('ProductGroupID', postgresql.UUID(), nullable=False),
sa.Column('account_id', postgresql.UUID(), nullable=False),
sa.Column('cost_price', sa.Numeric(), nullable=False),
sa.Column('sale_price', sa.Numeric(), nullable=False),
sa.Column('IsActive', sa.Boolean(), nullable=False),
sa.Column('IsFixture', sa.Boolean(), nullable=False),
sa.Column('is_purchased', sa.Boolean(), nullable=False),
sa.Column('is_sold', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['ProductGroupID'], ['product_groups.ProductGroupID'], name=op.f('fk_products_ProductGroupID_product_groups')),
sa.ForeignKeyConstraint(['account_id'], ['accounts.id'], name=op.f('fk_products_account_id_accounts')),
sa.PrimaryKeyConstraint('ProductID', name=op.f('pk_products')),
sa.UniqueConstraint('Code', name=op.f('uq_products_Code')),
sa.UniqueConstraint('Name', 'Units', name=op.f('uq_products_Name'))
op.create_index(op.f("ix_journals_VoucherID"), "journals", ["VoucherID"], unique=False)
op.create_table(
"products",
sa.Column("ProductID", postgresql.UUID(), nullable=False),
sa.Column("Code", sa.Integer(), nullable=True),
sa.Column("Name", sa.Unicode(length=255), nullable=False),
sa.Column("Units", sa.Unicode(length=255), nullable=False),
sa.Column("Fraction", sa.Numeric(), nullable=False),
sa.Column("FractionUnits", sa.Unicode(length=255), nullable=False),
sa.Column("ProductYield", sa.Numeric(), nullable=False),
sa.Column("ProductGroupID", postgresql.UUID(), nullable=False),
sa.Column("account_id", postgresql.UUID(), nullable=False),
sa.Column("cost_price", sa.Numeric(), nullable=False),
sa.Column("sale_price", sa.Numeric(), nullable=False),
sa.Column("IsActive", sa.Boolean(), nullable=False),
sa.Column("IsFixture", sa.Boolean(), nullable=False),
sa.Column("is_purchased", sa.Boolean(), nullable=False),
sa.Column("is_sold", sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(
["ProductGroupID"],
["product_groups.ProductGroupID"],
name=op.f("fk_products_ProductGroupID_product_groups"),
),
sa.ForeignKeyConstraint(["account_id"], ["accounts.id"], name=op.f("fk_products_account_id_accounts"),),
sa.PrimaryKeyConstraint("ProductID", name=op.f("pk_products")),
sa.UniqueConstraint("Code", name=op.f("uq_products_Code")),
sa.UniqueConstraint("Name", "Units", name=op.f("uq_products_Name")),
)
op.create_table('attendances',
sa.Column('AttendanceID', postgresql.UUID(), nullable=False),
sa.Column('EmployeeID', postgresql.UUID(), nullable=True),
sa.Column('Date', sa.DateTime(), nullable=True),
sa.Column('AttendanceType', sa.Integer(), nullable=True),
sa.Column('Amount', sa.Numeric(), nullable=True),
sa.Column('CreationDate', sa.DateTime(timezone=True), nullable=True),
sa.Column('UserID', postgresql.UUID(), nullable=True),
sa.Column('IsValid', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['EmployeeID'], ['employees.id'], name=op.f('fk_attendances_EmployeeID_employees')),
sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name=op.f('fk_attendances_UserID_auth_users')),
sa.PrimaryKeyConstraint('AttendanceID', name=op.f('pk_attendances'))
op.create_table(
"attendances",
sa.Column("AttendanceID", postgresql.UUID(), nullable=False),
sa.Column("EmployeeID", postgresql.UUID(), nullable=True),
sa.Column("Date", sa.DateTime(), nullable=True),
sa.Column("AttendanceType", sa.Integer(), nullable=True),
sa.Column("Amount", sa.Numeric(), nullable=True),
sa.Column("CreationDate", sa.DateTime(timezone=True), nullable=True),
sa.Column("UserID", postgresql.UUID(), nullable=True),
sa.Column("IsValid", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(["EmployeeID"], ["employees.id"], name=op.f("fk_attendances_EmployeeID_employees"),),
sa.ForeignKeyConstraint(["UserID"], ["auth_users.UserID"], name=op.f("fk_attendances_UserID_auth_users"),),
sa.PrimaryKeyConstraint("AttendanceID", name=op.f("pk_attendances")),
)
op.create_table('batches',
sa.Column('BatchID', postgresql.UUID(), nullable=False),
sa.Column('Name', sa.DateTime(), nullable=True),
sa.Column('ProductID', postgresql.UUID(), nullable=False),
sa.Column('QuantityRemaining', sa.Numeric(), nullable=True),
sa.Column('Rate', sa.Numeric(), nullable=True),
sa.Column('Tax', sa.Numeric(), nullable=True),
sa.Column('Discount', sa.Numeric(), nullable=True),
sa.ForeignKeyConstraint(['ProductID'], ['products.ProductID'], name=op.f('fk_batches_ProductID_products')),
sa.PrimaryKeyConstraint('BatchID', name=op.f('pk_batches'))
op.create_table(
"batches",
sa.Column("BatchID", postgresql.UUID(), nullable=False),
sa.Column("Name", sa.DateTime(), nullable=True),
sa.Column("ProductID", postgresql.UUID(), nullable=False),
sa.Column("QuantityRemaining", sa.Numeric(), nullable=True),
sa.Column("Rate", sa.Numeric(), nullable=True),
sa.Column("Tax", sa.Numeric(), nullable=True),
sa.Column("Discount", sa.Numeric(), nullable=True),
sa.ForeignKeyConstraint(["ProductID"], ["products.ProductID"], name=op.f("fk_batches_ProductID_products"),),
sa.PrimaryKeyConstraint("BatchID", name=op.f("pk_batches")),
)
op.create_table('fingerprints',
sa.Column('FingerprintID', postgresql.UUID(), nullable=False),
sa.Column('EmployeeID', postgresql.UUID(), nullable=True),
sa.Column('Date', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['EmployeeID'], ['employees.id'], name=op.f('fk_fingerprints_EmployeeID_employees')),
sa.PrimaryKeyConstraint('FingerprintID', name=op.f('pk_fingerprints'))
op.create_table(
"fingerprints",
sa.Column("FingerprintID", postgresql.UUID(), nullable=False),
sa.Column("EmployeeID", postgresql.UUID(), nullable=True),
sa.Column("Date", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(["EmployeeID"], ["employees.id"], name=op.f("fk_fingerprints_EmployeeID_employees"),),
sa.PrimaryKeyConstraint("FingerprintID", name=op.f("pk_fingerprints")),
)
op.create_table('recipes',
sa.Column('recipe_id', postgresql.UUID(), nullable=False),
sa.Column('product_id', postgresql.UUID(), nullable=False),
sa.Column('quantity', sa.Numeric(), nullable=False),
sa.Column('cost_price', sa.Numeric(), nullable=False),
sa.Column('sale_price', sa.Numeric(), nullable=False),
sa.Column('notes', sa.Unicode(length=255), nullable=True),
sa.Column('valid_from', sa.Date(), nullable=False),
sa.Column('valid_to', sa.Date(), nullable=False),
sa.Column('effective_from', sa.Date(), nullable=False),
sa.Column('effective_to', sa.Date(), nullable=True),
sa.ForeignKeyConstraint(['product_id'], ['products.ProductID'], name=op.f('fk_recipes_product_id_products')),
sa.PrimaryKeyConstraint('recipe_id', name=op.f('pk_recipes'))
op.create_table(
"recipes",
sa.Column("recipe_id", postgresql.UUID(), nullable=False),
sa.Column("product_id", postgresql.UUID(), nullable=False),
sa.Column("quantity", sa.Numeric(), nullable=False),
sa.Column("cost_price", sa.Numeric(), nullable=False),
sa.Column("sale_price", sa.Numeric(), nullable=False),
sa.Column("notes", sa.Unicode(length=255), nullable=True),
sa.Column("valid_from", sa.Date(), nullable=False),
sa.Column("valid_to", sa.Date(), nullable=False),
sa.Column("effective_from", sa.Date(), nullable=False),
sa.Column("effective_to", sa.Date(), nullable=True),
sa.ForeignKeyConstraint(["product_id"], ["products.ProductID"], name=op.f("fk_recipes_product_id_products"),),
sa.PrimaryKeyConstraint("recipe_id", name=op.f("pk_recipes")),
)
op.create_table('salary_deductions',
sa.Column('SalaryDeductionID', postgresql.UUID(), nullable=False),
sa.Column('VoucherID', postgresql.UUID(), nullable=False),
sa.Column('JournalID', postgresql.UUID(), nullable=False),
sa.Column('GrossSalary', sa.Integer(), nullable=True),
sa.Column('DaysWorked', sa.Integer(), nullable=True),
sa.Column('EsiEmployee', sa.Integer(), nullable=True),
sa.Column('PfEmployee', sa.Integer(), nullable=True),
sa.Column('EsiEmployer', sa.Integer(), nullable=True),
sa.Column('PfEmployer', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['JournalID'], ['journals.JournalID'], name=op.f('fk_salary_deductions_JournalID_journals')),
sa.ForeignKeyConstraint(['VoucherID'], ['vouchers.VoucherID'], name=op.f('fk_salary_deductions_VoucherID_vouchers')),
sa.PrimaryKeyConstraint('SalaryDeductionID', name=op.f('pk_salary_deductions'))
op.create_table(
"salary_deductions",
sa.Column("SalaryDeductionID", postgresql.UUID(), nullable=False),
sa.Column("VoucherID", postgresql.UUID(), nullable=False),
sa.Column("JournalID", postgresql.UUID(), nullable=False),
sa.Column("GrossSalary", sa.Integer(), nullable=True),
sa.Column("DaysWorked", sa.Integer(), nullable=True),
sa.Column("EsiEmployee", sa.Integer(), nullable=True),
sa.Column("PfEmployee", sa.Integer(), nullable=True),
sa.Column("EsiEmployer", sa.Integer(), nullable=True),
sa.Column("PfEmployer", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
["JournalID"], ["journals.JournalID"], name=op.f("fk_salary_deductions_JournalID_journals"),
),
sa.ForeignKeyConstraint(
["VoucherID"], ["vouchers.VoucherID"], name=op.f("fk_salary_deductions_VoucherID_vouchers"),
),
sa.PrimaryKeyConstraint("SalaryDeductionID", name=op.f("pk_salary_deductions")),
)
op.create_table('service_charges',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('voucher_id', postgresql.UUID(), nullable=False),
sa.Column('journal_id', postgresql.UUID(), nullable=False),
sa.Column('days_worked', sa.Integer(), nullable=False),
sa.Column('points', sa.Numeric(precision=5, scale=2), nullable=False),
sa.ForeignKeyConstraint(['journal_id'], ['journals.JournalID'], name=op.f('fk_service_charges_journal_id_journals')),
sa.ForeignKeyConstraint(['voucher_id'], ['vouchers.VoucherID'], name=op.f('fk_service_charges_voucher_id_vouchers')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_service_charges'))
op.create_table(
"service_charges",
sa.Column("id", postgresql.UUID(), nullable=False),
sa.Column("voucher_id", postgresql.UUID(), nullable=False),
sa.Column("journal_id", postgresql.UUID(), nullable=False),
sa.Column("days_worked", sa.Integer(), nullable=False),
sa.Column("points", sa.Numeric(precision=5, scale=2), nullable=False),
sa.ForeignKeyConstraint(
["journal_id"], ["journals.JournalID"], name=op.f("fk_service_charges_journal_id_journals"),
),
sa.ForeignKeyConstraint(
["voucher_id"], ["vouchers.VoucherID"], name=op.f("fk_service_charges_voucher_id_vouchers"),
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_service_charges")),
)
op.create_table('inventories',
sa.Column('InventoryID', postgresql.UUID(), nullable=False),
sa.Column('VoucherID', postgresql.UUID(), nullable=False),
sa.Column('ProductID', postgresql.UUID(), nullable=False),
sa.Column('BatchID', postgresql.UUID(), nullable=False),
sa.Column('Quantity', sa.Numeric(), nullable=True),
sa.Column('Rate', sa.Numeric(), nullable=True),
sa.Column('Tax', sa.Numeric(), nullable=True),
sa.Column('Discount', sa.Numeric(), nullable=True),
sa.ForeignKeyConstraint(['BatchID'], ['batches.BatchID'], name=op.f('fk_inventories_BatchID_batches')),
sa.ForeignKeyConstraint(['ProductID'], ['products.ProductID'], name=op.f('fk_inventories_ProductID_products')),
sa.ForeignKeyConstraint(['VoucherID'], ['vouchers.VoucherID'], name=op.f('fk_inventories_VoucherID_vouchers')),
sa.PrimaryKeyConstraint('InventoryID', name=op.f('pk_inventories')),
sa.UniqueConstraint('VoucherID', 'BatchID', name=op.f('uq_inventories_VoucherID'))
op.create_table(
"inventories",
sa.Column("InventoryID", postgresql.UUID(), nullable=False),
sa.Column("VoucherID", postgresql.UUID(), nullable=False),
sa.Column("ProductID", postgresql.UUID(), nullable=False),
sa.Column("BatchID", postgresql.UUID(), nullable=False),
sa.Column("Quantity", sa.Numeric(), nullable=True),
sa.Column("Rate", sa.Numeric(), nullable=True),
sa.Column("Tax", sa.Numeric(), nullable=True),
sa.Column("Discount", sa.Numeric(), nullable=True),
sa.ForeignKeyConstraint(["BatchID"], ["batches.BatchID"], name=op.f("fk_inventories_BatchID_batches"),),
sa.ForeignKeyConstraint(["ProductID"], ["products.ProductID"], name=op.f("fk_inventories_ProductID_products"),),
sa.ForeignKeyConstraint(["VoucherID"], ["vouchers.VoucherID"], name=op.f("fk_inventories_VoucherID_vouchers"),),
sa.PrimaryKeyConstraint("InventoryID", name=op.f("pk_inventories")),
sa.UniqueConstraint("VoucherID", "BatchID", name=op.f("uq_inventories_VoucherID")),
)
op.create_index(op.f('ix_inventories_VoucherID'), 'inventories', ['VoucherID'], unique=False)
op.create_table('recipe_items',
sa.Column('recipe_item_id', postgresql.UUID(), nullable=False),
sa.Column('recipe_id', postgresql.UUID(), nullable=False),
sa.Column('product_id', postgresql.UUID(), nullable=False),
sa.Column('quantity', sa.Integer(), nullable=False),
sa.Column('price', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['product_id'], ['products.ProductID'], name=op.f('fk_recipe_items_product_id_products')),
sa.ForeignKeyConstraint(['recipe_id'], ['recipes.recipe_id'], name=op.f('fk_recipe_items_recipe_id_recipes')),
sa.PrimaryKeyConstraint('recipe_item_id', name=op.f('pk_recipe_items')),
sa.UniqueConstraint('recipe_id', 'product_id', name=op.f('uq_recipe_items_recipe_id'))
op.create_index(op.f("ix_inventories_VoucherID"), "inventories", ["VoucherID"], unique=False)
op.create_table(
"recipe_items",
sa.Column("recipe_item_id", postgresql.UUID(), nullable=False),
sa.Column("recipe_id", postgresql.UUID(), nullable=False),
sa.Column("product_id", postgresql.UUID(), nullable=False),
sa.Column("quantity", sa.Integer(), nullable=False),
sa.Column("price", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["product_id"], ["products.ProductID"], name=op.f("fk_recipe_items_product_id_products"),
),
sa.ForeignKeyConstraint(["recipe_id"], ["recipes.recipe_id"], name=op.f("fk_recipe_items_recipe_id_recipes"),),
sa.PrimaryKeyConstraint("recipe_item_id", name=op.f("pk_recipe_items")),
sa.UniqueConstraint("recipe_id", "product_id", name=op.f("uq_recipe_items_recipe_id")),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('recipe_items')
op.drop_index(op.f('ix_inventories_VoucherID'), table_name='inventories')
op.drop_table('inventories')
op.drop_table('service_charges')
op.drop_table('salary_deductions')
op.drop_table('recipes')
op.drop_table('fingerprints')
op.drop_table('batches')
op.drop_table('attendances')
op.drop_table('products')
op.drop_index(op.f('ix_journals_VoucherID'), table_name='journals')
op.drop_table('journals')
op.drop_table('employees')
op.drop_index(op.f('ix_vouchers_date'), table_name='vouchers')
op.drop_table('vouchers')
op.drop_table('auth_usergroups')
op.drop_table('auth_rolegroups')
op.drop_table('auth_login_history')
op.drop_table('accounts')
op.drop_table('settings')
op.drop_table('product_groups')
op.drop_table('images')
op.drop_table('cost_centres')
op.drop_table('auth_users')
op.drop_table('auth_roles')
op.drop_table('auth_groups')
op.drop_table('auth_clients')
op.drop_table("recipe_items")
op.drop_index(op.f("ix_inventories_VoucherID"), table_name="inventories")
op.drop_table("inventories")
op.drop_table("service_charges")
op.drop_table("salary_deductions")
op.drop_table("recipes")
op.drop_table("fingerprints")
op.drop_table("batches")
op.drop_table("attendances")
op.drop_table("products")
op.drop_index(op.f("ix_journals_VoucherID"), table_name="journals")
op.drop_table("journals")
op.drop_table("employees")
op.drop_index(op.f("ix_vouchers_date"), table_name="vouchers")
op.drop_table("vouchers")
op.drop_table("auth_usergroups")
op.drop_table("auth_rolegroups")
op.drop_table("auth_login_history")
op.drop_table("accounts")
op.drop_table("settings")
op.drop_table("product_groups")
op.drop_table("images")
op.drop_table("cost_centres")
op.drop_table("auth_users")
op.drop_table("auth_roles")
op.drop_table("auth_groups")
op.drop_table("auth_clients")
# ### end Alembic commands ###

View File

@ -11,206 +11,235 @@ from sqlalchemy import table, column, select
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'eed0b382c287'
down_revision = '0bf3d70ee7de'
revision = "eed0b382c287"
down_revision = "0bf3d70ee7de"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('msg_subscribers')
op.drop_table('msg_posts')
op.drop_table('msg_threadtags')
op.drop_table('msg_threads')
op.drop_table('msg_tags')
op.drop_table("msg_subscribers")
op.drop_table("msg_posts")
op.drop_table("msg_threadtags")
op.drop_table("msg_threads")
op.drop_table("msg_tags")
op.rename_table('auth_roles', 'auth_permissions')
op.rename_table("auth_roles", "auth_permissions")
with op.batch_alter_table("auth_permissions") as batch_op:
batch_op.alter_column('RoleID', new_column_name='id')
batch_op.alter_column('Name', new_column_name='name')
batch_op.alter_column("RoleID", new_column_name="id")
batch_op.alter_column("Name", new_column_name="name")
op.rename_table('auth_groups', 'auth_roles')
op.rename_table("auth_groups", "auth_roles")
with op.batch_alter_table("auth_roles") as batch_op:
batch_op.alter_column('GroupID', new_column_name='id')
batch_op.alter_column('Name', new_column_name='name')
batch_op.alter_column("GroupID", new_column_name="id")
batch_op.alter_column("Name", new_column_name="name")
op.rename_table('auth_rolegroups', 'role_permissions')
op.rename_table("auth_rolegroups", "role_permissions")
with op.batch_alter_table("role_permissions") as batch_op:
batch_op.alter_column('RoleGroupID', new_column_name='id')
batch_op.alter_column('RoleID', new_column_name='permission_id')
batch_op.alter_column('GroupID', new_column_name='role_id')
batch_op.alter_column("RoleGroupID", new_column_name="id")
batch_op.alter_column("RoleID", new_column_name="permission_id")
batch_op.alter_column("GroupID", new_column_name="role_id")
op.rename_table('auth_usergroups', 'user_roles')
op.rename_table("auth_usergroups", "user_roles")
with op.batch_alter_table("user_roles") as batch_op:
batch_op.alter_column('UserGroupID', new_column_name='id')
batch_op.alter_column('UserID', new_column_name='user_id')
batch_op.alter_column('GroupID', new_column_name='role_id')
batch_op.alter_column("UserGroupID", new_column_name="id")
batch_op.alter_column("UserID", new_column_name="user_id")
batch_op.alter_column("GroupID", new_column_name="role_id")
with op.batch_alter_table("attendances") as batch_op:
batch_op.alter_column('Amount', new_column_name='amount')
batch_op.alter_column('UserID', new_column_name='user_id')
batch_op.alter_column('AttendanceType', new_column_name='attendance_type')
batch_op.alter_column('CreationDate', new_column_name='creation_date')
batch_op.alter_column('Date', new_column_name='date', type_=sa.Date(), nullable=False)
batch_op.alter_column('EmployeeID', new_column_name='employee_id')
batch_op.alter_column('AttendanceID', new_column_name='id')
batch_op.alter_column('IsValid', new_column_name='is_valid')
batch_op.alter_column("Amount", new_column_name="amount")
batch_op.alter_column("UserID", new_column_name="user_id")
batch_op.alter_column("AttendanceType", new_column_name="attendance_type")
batch_op.alter_column("CreationDate", new_column_name="creation_date")
batch_op.alter_column("Date", new_column_name="date", type_=sa.Date(), nullable=False)
batch_op.alter_column("EmployeeID", new_column_name="employee_id")
batch_op.alter_column("AttendanceID", new_column_name="id")
batch_op.alter_column("IsValid", new_column_name="is_valid")
with op.batch_alter_table("auth_users") as batch_op:
batch_op.alter_column('UserID', new_column_name='id')
batch_op.alter_column('Name', new_column_name='username')
batch_op.alter_column('Password', new_column_name='password')
batch_op.alter_column('LockedOut', new_column_name='disabled')
batch_op.alter_column("UserID", new_column_name="id")
batch_op.alter_column("Name", new_column_name="username")
batch_op.alter_column("Password", new_column_name="password")
batch_op.alter_column("LockedOut", new_column_name="disabled")
with op.batch_alter_table("batches") as batch_op:
batch_op.alter_column('BatchID', new_column_name='id')
batch_op.alter_column('Discount', new_column_name='discount')
batch_op.alter_column('Name', new_column_name='name', type_=sa.Date(), nullable=False)
batch_op.alter_column('ProductID', new_column_name='product_id')
batch_op.alter_column('QuantityRemaining', new_column_name='quantity_remaining')
batch_op.alter_column('Rate', new_column_name='rate')
batch_op.alter_column('Tax', new_column_name='tax')
batch_op.alter_column("BatchID", new_column_name="id")
batch_op.alter_column("Discount", new_column_name="discount")
batch_op.alter_column("Name", new_column_name="name", type_=sa.Date(), nullable=False)
batch_op.alter_column("ProductID", new_column_name="product_id")
batch_op.alter_column("QuantityRemaining", new_column_name="quantity_remaining")
batch_op.alter_column("Rate", new_column_name="rate")
batch_op.alter_column("Tax", new_column_name="tax")
with op.batch_alter_table("cost_centres") as batch_op:
batch_op.alter_column('CostCentreID', new_column_name='id')
batch_op.alter_column('Name', new_column_name='name')
batch_op.alter_column('IsFixture', new_column_name='is_fixture')
batch_op.alter_column("CostCentreID", new_column_name="id")
batch_op.alter_column("Name", new_column_name="name")
batch_op.alter_column("IsFixture", new_column_name="is_fixture")
with op.batch_alter_table("product_groups") as batch_op:
batch_op.alter_column('ProductGroupID', new_column_name='id')
batch_op.alter_column('Name', new_column_name='name')
batch_op.alter_column('IsFixture', new_column_name='is_fixture')
batch_op.alter_column("ProductGroupID", new_column_name="id")
batch_op.alter_column("Name", new_column_name="name")
batch_op.alter_column("IsFixture", new_column_name="is_fixture")
with op.batch_alter_table("inventories") as batch_op:
batch_op.alter_column('InventoryID', new_column_name='id')
batch_op.alter_column('BatchID', new_column_name='batch_id')
batch_op.alter_column('Discount', new_column_name='discount')
batch_op.alter_column('ProductID', new_column_name='product_id')
batch_op.alter_column('Quantity', new_column_name='quantity')
batch_op.alter_column('Rate', new_column_name='rate')
batch_op.alter_column('Tax', new_column_name='tax')
batch_op.alter_column('VoucherID', new_column_name='voucher_id')
batch_op.alter_column("InventoryID", new_column_name="id")
batch_op.alter_column("BatchID", new_column_name="batch_id")
batch_op.alter_column("Discount", new_column_name="discount")
batch_op.alter_column("ProductID", new_column_name="product_id")
batch_op.alter_column("Quantity", new_column_name="quantity")
batch_op.alter_column("Rate", new_column_name="rate")
batch_op.alter_column("Tax", new_column_name="tax")
batch_op.alter_column("VoucherID", new_column_name="voucher_id")
with op.batch_alter_table("journals") as batch_op:
batch_op.alter_column('Amount', new_column_name='amount')
batch_op.alter_column('CostCentreID', new_column_name='cost_centre_id')
batch_op.alter_column('Debit', new_column_name='debit')
batch_op.alter_column('JournalID', new_column_name='id')
batch_op.alter_column('VoucherID', new_column_name='voucher_id')
batch_op.alter_column("Amount", new_column_name="amount")
batch_op.alter_column("CostCentreID", new_column_name="cost_centre_id")
batch_op.alter_column("Debit", new_column_name="debit")
batch_op.alter_column("JournalID", new_column_name="id")
batch_op.alter_column("VoucherID", new_column_name="voucher_id")
with op.batch_alter_table("fingerprints") as batch_op:
batch_op.alter_column('FingerprintID', new_column_name='id')
batch_op.alter_column('Date', new_column_name='date')
batch_op.alter_column('EmployeeID', new_column_name='employee_id')
batch_op.alter_column("FingerprintID", new_column_name="id")
batch_op.alter_column("Date", new_column_name="date")
batch_op.alter_column("EmployeeID", new_column_name="employee_id")
with op.batch_alter_table("products") as batch_op:
batch_op.alter_column('ProductID', new_column_name='id')
batch_op.alter_column('Code', new_column_name='code')
batch_op.alter_column('Fraction', new_column_name='fraction')
batch_op.alter_column('FractionUnits', new_column_name='fraction_units')
batch_op.alter_column('IsActive', new_column_name='is_active')
batch_op.alter_column('IsFixture', new_column_name='is_fixture')
batch_op.alter_column('Name', new_column_name='name')
batch_op.alter_column('ProductGroupID', new_column_name='product_group_id')
batch_op.alter_column('ProductYield', new_column_name='product_yield')
batch_op.alter_column('Units', new_column_name='units')
batch_op.alter_column("ProductID", new_column_name="id")
batch_op.alter_column("Code", new_column_name="code")
batch_op.alter_column("Fraction", new_column_name="fraction")
batch_op.alter_column("FractionUnits", new_column_name="fraction_units")
batch_op.alter_column("IsActive", new_column_name="is_active")
batch_op.alter_column("IsFixture", new_column_name="is_fixture")
batch_op.alter_column("Name", new_column_name="name")
batch_op.alter_column("ProductGroupID", new_column_name="product_group_id")
batch_op.alter_column("ProductYield", new_column_name="product_yield")
batch_op.alter_column("Units", new_column_name="units")
with op.batch_alter_table("recipes") as batch_op:
batch_op.alter_column('recipe_id', new_column_name='id')
batch_op.alter_column("recipe_id", new_column_name="id")
op.rename_table('salary_deductions', 'employee_benefit')
op.rename_table("salary_deductions", "employee_benefit")
with op.batch_alter_table("employee_benefit") as batch_op:
batch_op.alter_column('SalaryDeductionID', new_column_name='id')
batch_op.alter_column('DaysWorked', new_column_name='days_worked')
batch_op.alter_column('EsiEmployee', new_column_name='esi_employee')
batch_op.alter_column('EsiEmployer', new_column_name='esi_employer')
batch_op.alter_column('GrossSalary', new_column_name='gross_salary')
batch_op.alter_column('JournalID', new_column_name='journal_id')
batch_op.alter_column('PfEmployee', new_column_name='pf_employee')
batch_op.alter_column('PfEmployer', new_column_name='pf_employer')
batch_op.alter_column('VoucherID', new_column_name='voucher_id')
batch_op.alter_column("SalaryDeductionID", new_column_name="id")
batch_op.alter_column("DaysWorked", new_column_name="days_worked")
batch_op.alter_column("EsiEmployee", new_column_name="esi_employee")
batch_op.alter_column("EsiEmployer", new_column_name="esi_employer")
batch_op.alter_column("GrossSalary", new_column_name="gross_salary")
batch_op.alter_column("JournalID", new_column_name="journal_id")
batch_op.alter_column("PfEmployee", new_column_name="pf_employee")
batch_op.alter_column("PfEmployer", new_column_name="pf_employer")
batch_op.alter_column("VoucherID", new_column_name="voucher_id")
with op.batch_alter_table("vouchers") as batch_op:
batch_op.alter_column('VoucherID', new_column_name='id')
batch_op.alter_column('date', type_=sa.Date(), nullable=False)
batch_op.alter_column('reconcile_date', type_=sa.Date(), nullable=False)
batch_op.alter_column("VoucherID", new_column_name="id")
batch_op.alter_column("date", type_=sa.Date(), nullable=False)
batch_op.alter_column("reconcile_date", type_=sa.Date(), nullable=False)
op.rename_table('service_charges', 'incentives')
op.rename_table("service_charges", "incentives")
with op.batch_alter_table("employees") as batch_op:
batch_op.alter_column('Designation', new_column_name='designation', nullable=False)
batch_op.alter_column('Salary', new_column_name='salary', nullable=False)
batch_op.alter_column('ServicePoints', new_column_name='points', nullable=False)
batch_op.alter_column('JoiningDate', new_column_name='joining_date', type_=sa.Date(), nullable=False)
batch_op.alter_column('LeavingDate', new_column_name='leaving_date', type_=sa.Date(), nullable=True)
batch_op.alter_column("Designation", new_column_name="designation", nullable=False)
batch_op.alter_column("Salary", new_column_name="salary", nullable=False)
batch_op.alter_column("ServicePoints", new_column_name="points", nullable=False)
batch_op.alter_column(
"JoiningDate", new_column_name="joining_date", type_=sa.Date(), nullable=False,
)
batch_op.alter_column(
"LeavingDate", new_column_name="leaving_date", type_=sa.Date(), nullable=True,
)
with op.batch_alter_table("settings") as batch_op:
batch_op.alter_column('SettingID', new_column_name='id')
batch_op.alter_column('Name', new_column_name='name')
batch_op.alter_column('Data', new_column_name='data')
batch_op.alter_column("SettingID", new_column_name="id")
batch_op.alter_column("Name", new_column_name="name")
batch_op.alter_column("Data", new_column_name="data")
op.create_unique_constraint(op.f("uq_accounts_name"), "accounts", ["name"])
op.drop_constraint("accounts_name_key", "accounts", type_="unique")
op.create_unique_constraint(op.f("uq_auth_clients_code"), "auth_clients", ["code"])
op.create_unique_constraint(op.f("uq_auth_clients_name"), "auth_clients", ["name"])
op.drop_constraint("auth_clients_Code_key", "auth_clients", type_="unique")
op.drop_constraint("auth_clients_Name_key", "auth_clients", type_="unique")
op.create_unique_constraint(
op.f("uq_auth_login_history_user_id"), "auth_login_history", ["user_id", "client_id", "date"],
)
op.drop_constraint(
"auth_login_history_user_id_client_id_date_key", "auth_login_history", type_="unique",
)
op.create_unique_constraint(op.f("uq_auth_permissions_name"), "auth_permissions", ["name"])
op.drop_constraint("auth_roles_Name_key", "auth_permissions", type_="unique")
op.create_unique_constraint(op.f("uq_auth_roles_name"), "auth_roles", ["name"])
op.drop_constraint("auth_groups_Name_key", "auth_roles", type_="unique")
op.create_unique_constraint(op.f("uq_auth_users_username"), "auth_users", ["username"])
op.drop_constraint("auth_users_Name_key", "auth_users", type_="unique")
op.create_unique_constraint(op.f("uq_cost_centres_name"), "cost_centres", ["name"])
op.drop_constraint("entities_costcenters_Name_key", "cost_centres", type_="unique")
op.drop_constraint("uq_employee_id_date", "fingerprints", type_="unique")
op.create_index(op.f("ix_inventories_voucher_id"), "inventories", ["voucher_id"], unique=False)
op.create_unique_constraint(op.f("uq_inventories_voucher_id"), "inventories", ["voucher_id", "batch_id"])
op.drop_index("ix_inventories_VoucherID", table_name="inventories")
op.create_index(op.f("ix_journals_voucher_id"), "journals", ["voucher_id"], unique=False)
op.drop_index("ix_journals_VoucherID", table_name="journals")
op.create_unique_constraint(op.f("uq_product_groups_name"), "product_groups", ["name"])
op.drop_constraint("entities_productgroups_Name_key", "product_groups", type_="unique")
op.create_unique_constraint(op.f("uq_products_code"), "products", ["code"])
op.create_unique_constraint(op.f("uq_products_name"), "products", ["name", "units"])
op.drop_constraint("products_Code_key", "products", type_="unique")
op.drop_constraint("products_Name_Units_key", "products", type_="unique")
op.create_unique_constraint(op.f("uq_recipe_items_recipe_id"), "recipe_items", ["recipe_id", "product_id"])
op.drop_constraint("recipe_items_recipe_id_product_id_key", "recipe_items", type_="unique")
op.create_unique_constraint(op.f("uq_settings_name"), "settings", ["name"])
op.drop_constraint("settings_Name_key", "settings", type_="unique")
op.create_index(op.f("ix_vouchers_date"), "vouchers", ["date"], unique=False)
op.create_foreign_key(
"fk_incentives_journal_id_journals", "incentives", "journals", ["journal_id"], ["id"],
)
op.create_foreign_key(
"fk_incentives_voucher_id_vouchers", "incentives", "vouchers", ["voucher_id"], ["id"],
)
op.drop_constraint("service_charges_journal_id_fkey", "incentives", type_="foreignkey")
op.drop_constraint("service_charges_voucher_id_fkey", "incentives", type_="foreignkey")
op.create_foreign_key(
"fk_employee_benefit_journal_id_journals", "employee_benefit", "journals", ["journal_id"], ["id"],
)
op.create_foreign_key(
"fk_employee_benefit_voucher_id_vouchers", "employee_benefit", "vouchers", ["voucher_id"], ["id"],
)
op.drop_constraint(
"entities_salarydeductions_JournalID_fkey", "employee_benefit", type_="foreignkey",
)
op.drop_constraint("salary_deductions_VoucherID_fkey", "employee_benefit", type_="foreignkey")
op.create_unique_constraint(op.f('uq_accounts_name'), 'accounts', ['name'])
op.drop_constraint('accounts_name_key', 'accounts', type_='unique')
op.create_unique_constraint(op.f('uq_auth_clients_code'), 'auth_clients', ['code'])
op.create_unique_constraint(op.f('uq_auth_clients_name'), 'auth_clients', ['name'])
op.drop_constraint('auth_clients_Code_key', 'auth_clients', type_='unique')
op.drop_constraint('auth_clients_Name_key', 'auth_clients', type_='unique')
op.create_unique_constraint(op.f('uq_auth_login_history_user_id'), 'auth_login_history', ['user_id', 'client_id', 'date'])
op.drop_constraint('auth_login_history_user_id_client_id_date_key', 'auth_login_history', type_='unique')
op.create_unique_constraint(op.f('uq_auth_permissions_name'), 'auth_permissions', ['name'])
op.drop_constraint('auth_roles_Name_key', 'auth_permissions', type_='unique')
op.create_unique_constraint(op.f('uq_auth_roles_name'), 'auth_roles', ['name'])
op.drop_constraint('auth_groups_Name_key', 'auth_roles', type_='unique')
op.create_unique_constraint(op.f('uq_auth_users_username'), 'auth_users', ['username'])
op.drop_constraint('auth_users_Name_key', 'auth_users', type_='unique')
op.create_unique_constraint(op.f('uq_cost_centres_name'), 'cost_centres', ['name'])
op.drop_constraint('entities_costcenters_Name_key', 'cost_centres', type_='unique')
op.drop_constraint('uq_employee_id_date', 'fingerprints', type_='unique')
op.create_index(op.f('ix_inventories_voucher_id'), 'inventories', ['voucher_id'], unique=False)
op.create_unique_constraint(op.f('uq_inventories_voucher_id'), 'inventories', ['voucher_id', 'batch_id'])
op.drop_index('ix_inventories_VoucherID', table_name='inventories')
op.create_index(op.f('ix_journals_voucher_id'), 'journals', ['voucher_id'], unique=False)
op.drop_index('ix_journals_VoucherID', table_name='journals')
op.create_unique_constraint(op.f('uq_product_groups_name'), 'product_groups', ['name'])
op.drop_constraint('entities_productgroups_Name_key', 'product_groups', type_='unique')
op.create_unique_constraint(op.f('uq_products_code'), 'products', ['code'])
op.create_unique_constraint(op.f('uq_products_name'), 'products', ['name', 'units'])
op.drop_constraint('products_Code_key', 'products', type_='unique')
op.drop_constraint('products_Name_Units_key', 'products', type_='unique')
op.create_unique_constraint(op.f('uq_recipe_items_recipe_id'), 'recipe_items', ['recipe_id', 'product_id'])
op.drop_constraint('recipe_items_recipe_id_product_id_key', 'recipe_items', type_='unique')
op.create_unique_constraint(op.f('uq_settings_name'), 'settings', ['name'])
op.drop_constraint('settings_Name_key', 'settings', type_='unique')
op.create_index(op.f('ix_vouchers_date'), 'vouchers', ['date'], unique=False)
op.create_foreign_key('fk_incentives_journal_id_journals', 'incentives', 'journals', ['journal_id'], ['id'])
op.create_foreign_key('fk_incentives_voucher_id_vouchers', 'incentives', 'vouchers', ['voucher_id'], ['id'])
op.drop_constraint('service_charges_journal_id_fkey', 'incentives', type_='foreignkey')
op.drop_constraint('service_charges_voucher_id_fkey', 'incentives', type_='foreignkey')
op.create_foreign_key('fk_employee_benefit_journal_id_journals', 'employee_benefit', 'journals', ['journal_id'], ['id'])
op.create_foreign_key('fk_employee_benefit_voucher_id_vouchers', 'employee_benefit', 'vouchers', ['voucher_id'], ['id'])
op.drop_constraint('entities_salarydeductions_JournalID_fkey', 'employee_benefit', type_='foreignkey')
op.drop_constraint('salary_deductions_VoucherID_fkey', 'employee_benefit', type_='foreignkey')
permission = table('auth_permissions', column('id', postgresql.UUID()), column('name', sa.String))
op.execute(permission.update().where(permission.c.name == op.inline_literal('Service Charge')).values({'name': op.inline_literal('Incentive')}))
op.execute(permission.update().where(permission.c.name == op.inline_literal('Salary Deduction')).values({'name': op.inline_literal('Employee Benefit')}))
account = table('accounts', column('name', sa.String))
op.execute(account.update().where(account.c.name == op.inline_literal('Service Charges')).values({'name': op.inline_literal('Incentives')}))
permission = table("auth_permissions", column("id", postgresql.UUID()), column("name", sa.String))
op.execute(
permission.update()
.where(permission.c.name == op.inline_literal("Service Charge"))
.values({"name": op.inline_literal("Incentive")})
)
op.execute(
permission.update()
.where(permission.c.name == op.inline_literal("Salary Deduction"))
.values({"name": op.inline_literal("Employee Benefit")})
)
account = table("accounts", column("name", sa.String))
op.execute(
account.update()
.where(account.c.name == op.inline_literal("Service Charges"))
.values({"name": op.inline_literal("Incentives")})
)
# Remove unneeded Payment and Receipt permissions
permission = table('auth_permissions', column('id', postgresql.UUID()), column('name', sa.String))
role_permission = table('role_permissions', column('permission_id', postgresql.UUID()), column('role_id', postgresql.UUID()))
permission = table("auth_permissions", column("id", postgresql.UUID()), column("name", sa.String))
role_permission = table(
"role_permissions", column("permission_id", postgresql.UUID()), column("role_id", postgresql.UUID()),
)
op.execute(
role_permission.delete().where(
role_permission.c.permission_id.in_(select([permission.c.id], permission.c.name.in_(['Payment', 'Receipt'])))
)
)
op.execute(
permission.delete().where(
permission.c.name.in_(['Payment', 'Receipt'])
role_permission.c.permission_id.in_(
select([permission.c.id], permission.c.name.in_(["Payment", "Receipt"]))
)
)
)
op.execute(permission.delete().where(permission.c.name.in_(["Payment", "Receipt"])))
### end Alembic commands ###