brewman/alembic/versions/eed0b382c287_lowercase_fast...

173 lines
9.5 KiB
Python
Raw Normal View History

2020-05-10 16:22:23 +00:00
"""my test
Revision ID: eed0b382c287
Revises: 0bf3d70ee7de
Create Date: 2020-05-10 19:52:58.163810
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
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.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')
2020-05-10 16:22:23 +00:00
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')
2020-05-10 16:22:23 +00:00
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')
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')
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')
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')
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')
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')
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')
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')
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')
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')
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')
with op.batch_alter_table("recipes") as batch_op:
batch_op.alter_column('recipe_id', new_column_name='id')
with op.batch_alter_table("salary_deductions") 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')
with op.batch_alter_table("vouchers") as batch_op:
batch_op.alter_column('VoucherID', new_column_name='id')
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)
### end Alembic commands ###
def downgrade():
raise Exception("Irreversible migration")