Added Alembic

Breaking: Changed a lot of column names
This commit is contained in:
tanshu
2020-05-10 20:36:19 +05:30
parent 9383cf84d4
commit 3cd7ff11f6
30 changed files with 2050 additions and 561 deletions

View File

@ -0,0 +1,314 @@
"""Initial Commit
Revision ID: 0bf3d70ee7de
Revises:
Create Date: 2020-05-10 19:02:57.301086
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '0bf3d70ee7de'
down_revision = None
branch_labels = None
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_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_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('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('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('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_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_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_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('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('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('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_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')
# ### end Alembic commands ###

View File

@ -0,0 +1,538 @@
"""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.create_table('auth_permissions',
sa.Column('id', brewman.models.guidtype.GUID(), nullable=False),
sa.Column('name', sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_auth_permissions')),
sa.UniqueConstraint('name', name=op.f('uq_auth_permissions_name'))
)
op.create_table('role_permissions',
sa.Column('id', brewman.models.guidtype.GUID(), nullable=False),
sa.Column('permission_id', brewman.models.guidtype.GUID(), nullable=True),
sa.Column('role_id', brewman.models.guidtype.GUID(), nullable=True),
sa.ForeignKeyConstraint(['permission_id'], ['auth_permissions.id'], name=op.f('fk_role_permissions_permission_id_auth_permissions')),
sa.ForeignKeyConstraint(['role_id'], ['auth_roles.id'], name=op.f('fk_role_permissions_role_id_auth_roles')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_role_permissions'))
)
op.create_table('user_roles',
sa.Column('id', brewman.models.guidtype.GUID(), nullable=False),
sa.Column('user_id', brewman.models.guidtype.GUID(), nullable=True),
sa.Column('role_id', brewman.models.guidtype.GUID(), nullable=True),
sa.ForeignKeyConstraint(['role_id'], ['auth_roles.id'], name=op.f('fk_user_roles_role_id_auth_roles')),
sa.ForeignKeyConstraint(['user_id'], ['auth_users.id'], name=op.f('fk_user_roles_user_id_auth_users')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_user_roles'))
)
op.drop_table('msg_subscribers')
op.drop_table('auth_rolegroups')
op.drop_table('auth_groups')
op.drop_table('msg_posts')
op.drop_table('msg_threadtags')
op.drop_table('msg_threads')
op.drop_table('msg_tags')
op.drop_table('auth_usergroups')
op.create_unique_constraint(op.f('uq_accounts_name'), 'accounts', ['name'])
op.drop_constraint('accounts_name_key', 'accounts', type_='unique')
op.drop_constraint('accounts_cost_centre_id_fkey', 'accounts', type_='foreignkey')
op.create_foreign_key(op.f('fk_accounts_cost_centre_id_cost_centres'), 'accounts', 'cost_centres', ['cost_centre_id'], ['id'])
op.add_column('attendances', sa.Column('amount', sa.Numeric(), nullable=True))
op.add_column('attendances', sa.Column('attendance_type', sa.Integer(), nullable=True))
op.add_column('attendances', sa.Column('creation_date', sa.DateTime(timezone=True), nullable=True))
op.add_column('attendances', sa.Column('date', sa.DateTime(), nullable=True))
op.add_column('attendances', sa.Column('employee_id', brewman.models.guidtype.GUID(), nullable=True))
op.add_column('attendances', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('attendances', sa.Column('is_valid', sa.Boolean(), nullable=True))
op.add_column('attendances', sa.Column('user_id', brewman.models.guidtype.GUID(), nullable=True))
op.drop_constraint('entities_attendances_UserID_fkey', 'attendances', type_='foreignkey')
op.drop_constraint('entities_attendances_EmployeeID_fkey', 'attendances', type_='foreignkey')
op.create_foreign_key(op.f('fk_attendances_employee_id_employees'), 'attendances', 'employees', ['employee_id'], ['id'])
op.create_foreign_key(op.f('fk_attendances_user_id_auth_users'), 'attendances', 'auth_users', ['user_id'], ['id'])
op.drop_column('attendances', 'CreationDate')
op.drop_column('attendances', 'EmployeeID')
op.drop_column('attendances', 'Date')
op.drop_column('attendances', 'AttendanceID')
op.drop_column('attendances', 'Amount')
op.drop_column('attendances', 'AttendanceType')
op.drop_column('attendances', 'IsValid')
op.drop_column('attendances', 'UserID')
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.drop_constraint('auth_login_history_user_id_fkey', 'auth_login_history', type_='foreignkey')
op.create_foreign_key(op.f('fk_auth_login_history_user_id_auth_users'), 'auth_login_history', 'auth_users', ['user_id'], ['id'])
op.add_column('auth_roles', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('auth_roles', sa.Column('name', sa.Unicode(length=255), nullable=True))
op.create_unique_constraint(op.f('uq_auth_roles_name'), 'auth_roles', ['name'])
op.drop_constraint('auth_roles_Name_key', 'auth_roles', type_='unique')
op.drop_column('auth_roles', 'RoleID')
op.drop_column('auth_roles', 'Name')
op.add_column('auth_users', sa.Column('disabled', sa.Boolean(), nullable=True))
op.add_column('auth_users', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('auth_users', sa.Column('password', sa.Unicode(length=60), nullable=True))
op.add_column('auth_users', sa.Column('username', sa.Unicode(length=255), nullable=True))
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.drop_column('auth_users', 'UserID')
op.drop_column('auth_users', 'Name')
op.drop_column('auth_users', 'Password')
op.drop_column('auth_users', 'LockedOut')
op.add_column('batches', sa.Column('discount', sa.Numeric(), nullable=True))
op.add_column('batches', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('batches', sa.Column('name', sa.DateTime(), nullable=True))
op.add_column('batches', sa.Column('product_id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('batches', sa.Column('quantity_remaining', sa.Numeric(), nullable=True))
op.add_column('batches', sa.Column('rate', sa.Numeric(), nullable=True))
op.add_column('batches', sa.Column('tax', sa.Numeric(), nullable=True))
op.drop_constraint('batches_ProductID_fkey', 'batches', type_='foreignkey')
op.create_foreign_key(op.f('fk_batches_product_id_products'), 'batches', 'products', ['product_id'], ['id'])
op.drop_column('batches', 'QuantityRemaining')
op.drop_column('batches', 'Rate')
op.drop_column('batches', 'Tax')
op.drop_column('batches', 'BatchID')
op.drop_column('batches', 'ProductID')
op.drop_column('batches', 'Name')
op.drop_column('batches', 'Discount')
op.add_column('cost_centres', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('cost_centres', sa.Column('is_fixture', sa.Boolean(), nullable=False))
op.add_column('cost_centres', sa.Column('name', sa.Unicode(length=255), nullable=True))
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_column('cost_centres', 'Name')
op.drop_column('cost_centres', 'IsFixture')
op.drop_column('cost_centres', 'CostCentreID')
op.add_column('fingerprints', sa.Column('date', sa.DateTime(), nullable=True))
op.add_column('fingerprints', sa.Column('employee_id', brewman.models.guidtype.GUID(), nullable=True))
op.add_column('fingerprints', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.drop_constraint('uq_employee_id_date', 'fingerprints', type_='unique')
op.drop_constraint('entities_fingerprints_EmployeeID_fkey', 'fingerprints', type_='foreignkey')
op.create_foreign_key(op.f('fk_fingerprints_employee_id_employees'), 'fingerprints', 'employees', ['employee_id'], ['id'])
op.drop_column('fingerprints', 'FingerprintID')
op.drop_column('fingerprints', 'EmployeeID')
op.drop_column('fingerprints', 'Date')
op.add_column('inventories', sa.Column('batch_id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('inventories', sa.Column('discount', sa.Numeric(), nullable=True))
op.add_column('inventories', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('inventories', sa.Column('product_id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('inventories', sa.Column('quantity', sa.Numeric(), nullable=True))
op.add_column('inventories', sa.Column('rate', sa.Numeric(), nullable=True))
op.add_column('inventories', sa.Column('tax', sa.Numeric(), nullable=True))
op.add_column('inventories', sa.Column('voucher_id', brewman.models.guidtype.GUID(), nullable=False))
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.drop_constraint('entities_inventories_BatchID_fkey', 'inventories', type_='foreignkey')
op.drop_constraint('inventories_VoucherID_fkey', 'inventories', type_='foreignkey')
op.drop_constraint('inventories_ProductID_fkey', 'inventories', type_='foreignkey')
op.create_foreign_key(op.f('fk_inventories_voucher_id_vouchers'), 'inventories', 'vouchers', ['voucher_id'], ['id'])
op.create_foreign_key(op.f('fk_inventories_batch_id_batches'), 'inventories', 'batches', ['batch_id'], ['id'])
op.create_foreign_key(op.f('fk_inventories_product_id_products'), 'inventories', 'products', ['product_id'], ['id'])
op.drop_column('inventories', 'InventoryID')
op.drop_column('inventories', 'VoucherID')
op.drop_column('inventories', 'Rate')
op.drop_column('inventories', 'Tax')
op.drop_column('inventories', 'BatchID')
op.drop_column('inventories', 'ProductID')
op.drop_column('inventories', 'Quantity')
op.drop_column('inventories', 'Discount')
op.add_column('journals', sa.Column('amount', sa.Numeric(), nullable=True))
op.add_column('journals', sa.Column('cost_centre_id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('journals', sa.Column('debit', sa.Integer(), nullable=True))
op.add_column('journals', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('journals', sa.Column('voucher_id', brewman.models.guidtype.GUID(), nullable=False))
op.create_index(op.f('ix_journals_voucher_id'), 'journals', ['voucher_id'], unique=False)
op.drop_index('ix_journals_VoucherID', table_name='journals')
op.drop_constraint('journals_VoucherID_fkey', 'journals', type_='foreignkey')
op.drop_constraint('entities_journals_CostCenterID_fkey', 'journals', type_='foreignkey')
op.create_foreign_key(op.f('fk_journals_cost_centre_id_cost_centres'), 'journals', 'cost_centres', ['cost_centre_id'], ['id'])
op.create_foreign_key(op.f('fk_journals_voucher_id_vouchers'), 'journals', 'vouchers', ['voucher_id'], ['id'])
op.drop_column('journals', 'Debit')
op.drop_column('journals', 'JournalID')
op.drop_column('journals', 'VoucherID')
op.drop_column('journals', 'Amount')
op.drop_column('journals', 'CostCentreID')
op.add_column('product_groups', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('product_groups', sa.Column('is_fixture', sa.Boolean(), nullable=False))
op.add_column('product_groups', sa.Column('name', sa.Unicode(length=255), nullable=True))
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.drop_column('product_groups', 'Name')
op.drop_column('product_groups', 'ProductGroupID')
op.drop_column('product_groups', 'IsFixture')
op.add_column('products', sa.Column('code', sa.Integer(), nullable=True))
op.add_column('products', sa.Column('fraction', sa.Numeric(), nullable=False))
op.add_column('products', sa.Column('fraction_units', sa.Unicode(length=255), nullable=False))
op.add_column('products', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('products', sa.Column('is_active', sa.Boolean(), nullable=False))
op.add_column('products', sa.Column('is_fixture', sa.Boolean(), nullable=False))
op.add_column('products', sa.Column('name', sa.Unicode(length=255), nullable=False))
op.add_column('products', sa.Column('product_group_id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('products', sa.Column('product_yield', sa.Numeric(), nullable=False))
op.add_column('products', sa.Column('units', sa.Unicode(length=255), nullable=False))
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.drop_constraint('products_ProductGroupID_fkey', 'products', type_='foreignkey')
op.create_foreign_key(op.f('fk_products_product_group_id_product_groups'), 'products', 'product_groups', ['product_group_id'], ['id'])
op.drop_column('products', 'Fraction')
op.drop_column('products', 'Units')
op.drop_column('products', 'ProductGroupID')
op.drop_column('products', 'IsFixture')
op.drop_column('products', 'FractionUnits')
op.drop_column('products', 'Code')
op.drop_column('products', 'ProductID')
op.drop_column('products', 'IsActive')
op.drop_column('products', 'Name')
op.drop_column('products', 'ProductYield')
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.drop_constraint('recipe_items_recipe_id_fkey', 'recipe_items', type_='foreignkey')
op.drop_constraint('recipe_items_product_id_fkey', 'recipe_items', type_='foreignkey')
op.create_foreign_key(op.f('fk_recipe_items_product_id_products'), 'recipe_items', 'products', ['product_id'], ['id'])
op.create_foreign_key(op.f('fk_recipe_items_recipe_id_recipes'), 'recipe_items', 'recipes', ['recipe_id'], ['id'])
op.add_column('recipes', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.drop_constraint('recipes_product_id_fkey', 'recipes', type_='foreignkey')
op.create_foreign_key(op.f('fk_recipes_product_id_products'), 'recipes', 'products', ['product_id'], ['id'])
op.drop_column('recipes', 'recipe_id')
op.add_column('salary_deductions', sa.Column('days_worked', sa.Integer(), nullable=True))
op.add_column('salary_deductions', sa.Column('esi_employee', sa.Integer(), nullable=True))
op.add_column('salary_deductions', sa.Column('esi_employer', sa.Integer(), nullable=True))
op.add_column('salary_deductions', sa.Column('gross_salary', sa.Integer(), nullable=True))
op.add_column('salary_deductions', sa.Column('id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('salary_deductions', sa.Column('journal_id', brewman.models.guidtype.GUID(), nullable=False))
op.add_column('salary_deductions', sa.Column('pf_employee', sa.Integer(), nullable=True))
op.add_column('salary_deductions', sa.Column('pf_employer', sa.Integer(), nullable=True))
op.add_column('salary_deductions', sa.Column('voucher_id', brewman.models.guidtype.GUID(), nullable=False))
op.drop_constraint('entities_salarydeductions_JournalID_fkey', 'salary_deductions', type_='foreignkey')
op.drop_constraint('salary_deductions_VoucherID_fkey', 'salary_deductions', type_='foreignkey')
op.create_foreign_key(op.f('fk_salary_deductions_voucher_id_vouchers'), 'salary_deductions', 'vouchers', ['voucher_id'], ['id'])
op.create_foreign_key(op.f('fk_salary_deductions_journal_id_journals'), 'salary_deductions', 'journals', ['journal_id'], ['id'])
op.drop_column('salary_deductions', 'JournalID')
op.drop_column('salary_deductions', 'VoucherID')
op.drop_column('salary_deductions', 'EsiEmployee')
op.drop_column('salary_deductions', 'PfEmployer')
op.drop_column('salary_deductions', 'DaysWorked')
op.drop_column('salary_deductions', 'GrossSalary')
op.drop_column('salary_deductions', 'PfEmployee')
op.drop_column('salary_deductions', 'SalaryDeductionID')
op.drop_column('salary_deductions', 'EsiEmployer')
op.drop_constraint('service_charges_journal_id_fkey', 'service_charges', type_='foreignkey')
op.drop_constraint('service_charges_voucher_id_fkey', 'service_charges', type_='foreignkey')
op.create_foreign_key(op.f('fk_service_charges_journal_id_journals'), 'service_charges', 'journals', ['journal_id'], ['id'])
op.create_foreign_key(op.f('fk_service_charges_voucher_id_vouchers'), 'service_charges', 'vouchers', ['voucher_id'], ['id'])
op.create_unique_constraint(op.f('uq_settings_Name'), 'settings', ['Name'])
op.drop_constraint('settings_Name_key', 'settings', type_='unique')
# op.add_column('vouchers', sa.Column('id', postgresql.UUID(), nullable=False))
op.create_index(op.f('ix_vouchers_date'), 'vouchers', ['date'], unique=False)
op.drop_constraint('vouchers_poster_id_fkey', 'vouchers', type_='foreignkey')
op.drop_constraint('vouchers_user_id_fkey', 'vouchers', type_='foreignkey')
op.create_foreign_key(op.f('fk_vouchers_user_id_auth_users'), 'vouchers', 'auth_users', ['user_id'], ['id'])
op.create_foreign_key(op.f('fk_vouchers_poster_id_auth_users'), 'vouchers', 'auth_users', ['poster_id'], ['id'])
with op.batch_alter_table("vouchers") as batch_op:
batch_op.alter_column('vouchers', 'VoucherID', new_column_name='id')
# op.drop_column('vouchers', 'VoucherID')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('vouchers', sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False))
op.drop_constraint(op.f('fk_vouchers_poster_id_auth_users'), 'vouchers', type_='foreignkey')
op.drop_constraint(op.f('fk_vouchers_user_id_auth_users'), 'vouchers', type_='foreignkey')
op.create_foreign_key('vouchers_user_id_fkey', 'vouchers', 'auth_users', ['user_id'], ['UserID'])
op.create_foreign_key('vouchers_poster_id_fkey', 'vouchers', 'auth_users', ['poster_id'], ['UserID'])
op.drop_index(op.f('ix_vouchers_date'), table_name='vouchers')
op.drop_column('vouchers', 'id')
op.create_unique_constraint('settings_Name_key', 'settings', ['Name'])
op.drop_constraint(op.f('uq_settings_Name'), 'settings', type_='unique')
op.drop_constraint(op.f('fk_service_charges_voucher_id_vouchers'), 'service_charges', type_='foreignkey')
op.drop_constraint(op.f('fk_service_charges_journal_id_journals'), 'service_charges', type_='foreignkey')
op.create_foreign_key('service_charges_voucher_id_fkey', 'service_charges', 'vouchers', ['voucher_id'], ['VoucherID'])
op.create_foreign_key('service_charges_journal_id_fkey', 'service_charges', 'journals', ['journal_id'], ['JournalID'])
op.add_column('salary_deductions', sa.Column('EsiEmployer', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('salary_deductions', sa.Column('SalaryDeductionID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('salary_deductions', sa.Column('PfEmployee', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('salary_deductions', sa.Column('GrossSalary', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('salary_deductions', sa.Column('DaysWorked', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('salary_deductions', sa.Column('PfEmployer', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('salary_deductions', sa.Column('EsiEmployee', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('salary_deductions', sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('salary_deductions', sa.Column('JournalID', postgresql.UUID(), autoincrement=False, nullable=False))
op.drop_constraint(op.f('fk_salary_deductions_journal_id_journals'), 'salary_deductions', type_='foreignkey')
op.drop_constraint(op.f('fk_salary_deductions_voucher_id_vouchers'), 'salary_deductions', type_='foreignkey')
op.create_foreign_key('salary_deductions_VoucherID_fkey', 'salary_deductions', 'vouchers', ['VoucherID'], ['VoucherID'])
op.create_foreign_key('entities_salarydeductions_JournalID_fkey', 'salary_deductions', 'journals', ['JournalID'], ['JournalID'])
op.drop_column('salary_deductions', 'voucher_id')
op.drop_column('salary_deductions', 'pf_employer')
op.drop_column('salary_deductions', 'pf_employee')
op.drop_column('salary_deductions', 'journal_id')
op.drop_column('salary_deductions', 'id')
op.drop_column('salary_deductions', 'gross_salary')
op.drop_column('salary_deductions', 'esi_employer')
op.drop_column('salary_deductions', 'esi_employee')
op.drop_column('salary_deductions', 'days_worked')
op.add_column('recipes', sa.Column('recipe_id', postgresql.UUID(), autoincrement=False, nullable=False))
op.drop_constraint(op.f('fk_recipes_product_id_products'), 'recipes', type_='foreignkey')
op.create_foreign_key('recipes_product_id_fkey', 'recipes', 'products', ['product_id'], ['ProductID'])
op.drop_column('recipes', 'id')
op.drop_constraint(op.f('fk_recipe_items_recipe_id_recipes'), 'recipe_items', type_='foreignkey')
op.drop_constraint(op.f('fk_recipe_items_product_id_products'), 'recipe_items', type_='foreignkey')
op.create_foreign_key('recipe_items_product_id_fkey', 'recipe_items', 'products', ['product_id'], ['ProductID'])
op.create_foreign_key('recipe_items_recipe_id_fkey', 'recipe_items', 'recipes', ['recipe_id'], ['recipe_id'])
op.create_unique_constraint('recipe_items_recipe_id_product_id_key', 'recipe_items', ['recipe_id', 'product_id'])
op.drop_constraint(op.f('uq_recipe_items_recipe_id'), 'recipe_items', type_='unique')
op.add_column('products', sa.Column('ProductYield', sa.NUMERIC(), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('IsActive', sa.BOOLEAN(), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('ProductID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('Code', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('products', sa.Column('FractionUnits', sa.VARCHAR(length=255), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('IsFixture', sa.BOOLEAN(), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('ProductGroupID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('Units', sa.VARCHAR(length=255), autoincrement=False, nullable=False))
op.add_column('products', sa.Column('Fraction', sa.NUMERIC(), autoincrement=False, nullable=False))
op.drop_constraint(op.f('fk_products_product_group_id_product_groups'), 'products', type_='foreignkey')
op.create_foreign_key('products_ProductGroupID_fkey', 'products', 'product_groups', ['ProductGroupID'], ['ProductGroupID'])
op.create_unique_constraint('products_Name_Units_key', 'products', ['Name', 'Units'])
op.create_unique_constraint('products_Code_key', 'products', ['Code'])
op.drop_constraint(op.f('uq_products_name'), 'products', type_='unique')
op.drop_constraint(op.f('uq_products_code'), 'products', type_='unique')
op.drop_column('products', 'units')
op.drop_column('products', 'product_yield')
op.drop_column('products', 'product_group_id')
op.drop_column('products', 'name')
op.drop_column('products', 'is_fixture')
op.drop_column('products', 'is_active')
op.drop_column('products', 'id')
op.drop_column('products', 'fraction_units')
op.drop_column('products', 'fraction')
op.drop_column('products', 'code')
op.add_column('product_groups', sa.Column('IsFixture', sa.BOOLEAN(), autoincrement=False, nullable=False))
op.add_column('product_groups', sa.Column('ProductGroupID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('product_groups', sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.create_unique_constraint('entities_productgroups_Name_key', 'product_groups', ['Name'])
op.drop_constraint(op.f('uq_product_groups_name'), 'product_groups', type_='unique')
op.drop_column('product_groups', 'name')
op.drop_column('product_groups', 'is_fixture')
op.drop_column('product_groups', 'id')
op.add_column('journals', sa.Column('CostCentreID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('journals', sa.Column('Amount', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('journals', sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('journals', sa.Column('JournalID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('journals', sa.Column('Debit', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_constraint(op.f('fk_journals_voucher_id_vouchers'), 'journals', type_='foreignkey')
op.drop_constraint(op.f('fk_journals_cost_centre_id_cost_centres'), 'journals', type_='foreignkey')
op.create_foreign_key('entities_journals_CostCenterID_fkey', 'journals', 'cost_centres', ['CostCentreID'], ['CostCentreID'])
op.create_foreign_key('journals_VoucherID_fkey', 'journals', 'vouchers', ['VoucherID'], ['VoucherID'])
op.create_index('ix_journals_VoucherID', 'journals', ['VoucherID'], unique=False)
op.drop_index(op.f('ix_journals_voucher_id'), table_name='journals')
op.drop_column('journals', 'voucher_id')
op.drop_column('journals', 'id')
op.drop_column('journals', 'debit')
op.drop_column('journals', 'cost_centre_id')
op.drop_column('journals', 'amount')
op.add_column('inventories', sa.Column('Discount', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('inventories', sa.Column('Quantity', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('inventories', sa.Column('ProductID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('inventories', sa.Column('BatchID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('inventories', sa.Column('Tax', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('inventories', sa.Column('Rate', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('inventories', sa.Column('VoucherID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('inventories', sa.Column('InventoryID', postgresql.UUID(), autoincrement=False, nullable=False))
op.drop_constraint(op.f('fk_inventories_product_id_products'), 'inventories', type_='foreignkey')
op.drop_constraint(op.f('fk_inventories_batch_id_batches'), 'inventories', type_='foreignkey')
op.drop_constraint(op.f('fk_inventories_voucher_id_vouchers'), 'inventories', type_='foreignkey')
op.create_foreign_key('inventories_ProductID_fkey', 'inventories', 'products', ['ProductID'], ['ProductID'])
op.create_foreign_key('inventories_VoucherID_fkey', 'inventories', 'vouchers', ['VoucherID'], ['VoucherID'])
op.create_foreign_key('entities_inventories_BatchID_fkey', 'inventories', 'batches', ['BatchID'], ['BatchID'])
op.create_index('ix_inventories_VoucherID', 'inventories', ['VoucherID'], unique=False)
op.drop_constraint(op.f('uq_inventories_voucher_id'), 'inventories', type_='unique')
op.drop_index(op.f('ix_inventories_voucher_id'), table_name='inventories')
op.drop_column('inventories', 'voucher_id')
op.drop_column('inventories', 'tax')
op.drop_column('inventories', 'rate')
op.drop_column('inventories', 'quantity')
op.drop_column('inventories', 'product_id')
op.drop_column('inventories', 'id')
op.drop_column('inventories', 'discount')
op.drop_column('inventories', 'batch_id')
op.add_column('fingerprints', sa.Column('Date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('fingerprints', sa.Column('EmployeeID', postgresql.UUID(), autoincrement=False, nullable=True))
op.add_column('fingerprints', sa.Column('FingerprintID', postgresql.UUID(), autoincrement=False, nullable=False))
op.drop_constraint(op.f('fk_fingerprints_employee_id_employees'), 'fingerprints', type_='foreignkey')
op.create_foreign_key('entities_fingerprints_EmployeeID_fkey', 'fingerprints', 'employees', ['EmployeeID'], ['id'])
op.create_unique_constraint('uq_employee_id_date', 'fingerprints', ['EmployeeID', 'Date'])
op.drop_column('fingerprints', 'id')
op.drop_column('fingerprints', 'employee_id')
op.drop_column('fingerprints', 'date')
op.add_column('cost_centres', sa.Column('CostCentreID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('cost_centres', sa.Column('IsFixture', sa.BOOLEAN(), autoincrement=False, nullable=False))
op.add_column('cost_centres', sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.create_unique_constraint('entities_costcenters_Name_key', 'cost_centres', ['Name'])
op.drop_constraint(op.f('uq_cost_centres_name'), 'cost_centres', type_='unique')
op.drop_column('cost_centres', 'name')
op.drop_column('cost_centres', 'is_fixture')
op.drop_column('cost_centres', 'id')
op.add_column('batches', sa.Column('Discount', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('batches', sa.Column('Name', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('batches', sa.Column('ProductID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('batches', sa.Column('BatchID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('batches', sa.Column('Tax', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('batches', sa.Column('Rate', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('batches', sa.Column('QuantityRemaining', sa.NUMERIC(), autoincrement=False, nullable=True))
op.drop_constraint(op.f('fk_batches_product_id_products'), 'batches', type_='foreignkey')
op.create_foreign_key('batches_ProductID_fkey', 'batches', 'products', ['ProductID'], ['ProductID'])
op.drop_column('batches', 'tax')
op.drop_column('batches', 'rate')
op.drop_column('batches', 'quantity_remaining')
op.drop_column('batches', 'product_id')
op.drop_column('batches', 'name')
op.drop_column('batches', 'id')
op.drop_column('batches', 'discount')
op.add_column('auth_users', sa.Column('LockedOut', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('auth_users', sa.Column('Password', sa.VARCHAR(length=60), autoincrement=False, nullable=True))
op.add_column('auth_users', sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('auth_users', sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False))
op.create_unique_constraint('auth_users_Name_key', 'auth_users', ['Name'])
op.drop_constraint(op.f('uq_auth_users_username'), 'auth_users', type_='unique')
op.drop_column('auth_users', 'username')
op.drop_column('auth_users', 'password')
op.drop_column('auth_users', 'id')
op.drop_column('auth_users', 'disabled')
op.add_column('auth_roles', sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('auth_roles', sa.Column('RoleID', postgresql.UUID(), autoincrement=False, nullable=False))
op.create_unique_constraint('auth_roles_Name_key', 'auth_roles', ['Name'])
op.drop_constraint(op.f('uq_auth_roles_name'), 'auth_roles', type_='unique')
op.drop_column('auth_roles', 'name')
op.drop_column('auth_roles', 'id')
op.drop_constraint(op.f('fk_auth_login_history_user_id_auth_users'), 'auth_login_history', type_='foreignkey')
op.create_foreign_key('auth_login_history_user_id_fkey', 'auth_login_history', 'auth_users', ['user_id'], ['UserID'])
op.create_unique_constraint('auth_login_history_user_id_client_id_date_key', 'auth_login_history', ['user_id', 'client_id', 'date'])
op.drop_constraint(op.f('uq_auth_login_history_user_id'), 'auth_login_history', type_='unique')
op.create_unique_constraint('auth_clients_Name_key', 'auth_clients', ['name'])
op.create_unique_constraint('auth_clients_Code_key', 'auth_clients', ['code'])
op.drop_constraint(op.f('uq_auth_clients_name'), 'auth_clients', type_='unique')
op.drop_constraint(op.f('uq_auth_clients_code'), 'auth_clients', type_='unique')
op.add_column('attendances', sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=True))
op.add_column('attendances', sa.Column('IsValid', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('attendances', sa.Column('AttendanceType', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('attendances', sa.Column('Amount', sa.NUMERIC(), autoincrement=False, nullable=True))
op.add_column('attendances', sa.Column('AttendanceID', postgresql.UUID(), autoincrement=False, nullable=False))
op.add_column('attendances', sa.Column('Date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('attendances', sa.Column('EmployeeID', postgresql.UUID(), autoincrement=False, nullable=True))
op.add_column('attendances', sa.Column('CreationDate', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
op.drop_constraint(op.f('fk_attendances_user_id_auth_users'), 'attendances', type_='foreignkey')
op.drop_constraint(op.f('fk_attendances_employee_id_employees'), 'attendances', type_='foreignkey')
op.create_foreign_key('entities_attendances_EmployeeID_fkey', 'attendances', 'employees', ['EmployeeID'], ['id'])
op.create_foreign_key('entities_attendances_UserID_fkey', 'attendances', 'auth_users', ['UserID'], ['UserID'])
op.drop_column('attendances', 'user_id')
op.drop_column('attendances', 'is_valid')
op.drop_column('attendances', 'id')
op.drop_column('attendances', 'employee_id')
op.drop_column('attendances', 'date')
op.drop_column('attendances', 'creation_date')
op.drop_column('attendances', 'attendance_type')
op.drop_column('attendances', 'amount')
op.drop_constraint(op.f('fk_accounts_cost_centre_id_cost_centres'), 'accounts', type_='foreignkey')
op.create_foreign_key('accounts_cost_centre_id_fkey', 'accounts', 'cost_centres', ['cost_centre_id'], ['CostCentreID'])
op.create_unique_constraint('accounts_name_key', 'accounts', ['name'])
op.drop_constraint(op.f('uq_accounts_name'), 'accounts', type_='unique')
op.create_table('auth_usergroups',
sa.Column('UserGroupID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=True),
sa.Column('GroupID', postgresql.UUID(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['GroupID'], ['auth_groups.GroupID'], name='auth_usergroups_GroupID_fkey'),
sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='auth_usergroups_UserID_fkey'),
sa.PrimaryKeyConstraint('UserGroupID', name='auth_usergroups_pkey')
)
op.create_table('msg_tags',
sa.Column('TagID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Name', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
sa.Column('CssClass', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('TagID', name='msg_tags_pkey'),
sa.UniqueConstraint('Name', name='msg_tags_Name_key'),
postgresql_ignore_search_path=False
)
op.create_table('msg_threads',
sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Title', sa.VARCHAR(length=1000), autoincrement=False, nullable=False),
sa.Column('CreationDate', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Priority', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('Public', sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.Column('Closed', sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='msg_threads_UserID_fkey'),
sa.PrimaryKeyConstraint('ThreadID', name='msg_threads_pkey'),
sa.UniqueConstraint('Title', name='msg_threads_Title_key'),
postgresql_ignore_search_path=False
)
op.create_table('msg_threadtags',
sa.Column('ThreadTagID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('TagID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['TagID'], ['msg_tags.TagID'], name='msg_threadtags_TagID_fkey'),
sa.ForeignKeyConstraint(['ThreadID'], ['msg_threads.ThreadID'], name='msg_threadtags_ThreadID_fkey'),
sa.PrimaryKeyConstraint('ThreadTagID', name='msg_threadtags_pkey'),
sa.UniqueConstraint('ThreadID', 'TagID', name='msg_threadtags_ThreadID_TagID_key')
)
op.create_table('msg_posts',
sa.Column('PostID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Content', sa.VARCHAR(length=1000), autoincrement=False, nullable=False),
sa.Column('CreationDate', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['ThreadID'], ['msg_threads.ThreadID'], name='msg_posts_ThreadID_fkey'),
sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='msg_posts_UserID_fkey'),
sa.PrimaryKeyConstraint('PostID', name='msg_posts_pkey')
)
op.create_table('auth_groups',
sa.Column('GroupID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Name', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('GroupID', name='auth_groups_pkey'),
sa.UniqueConstraint('Name', name='auth_groups_Name_key'),
postgresql_ignore_search_path=False
)
op.create_table('auth_rolegroups',
sa.Column('RoleGroupID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('RoleID', postgresql.UUID(), autoincrement=False, nullable=True),
sa.Column('GroupID', postgresql.UUID(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['GroupID'], ['auth_groups.GroupID'], name='auth_rolegroups_GroupID_fkey'),
sa.ForeignKeyConstraint(['RoleID'], ['auth_roles.RoleID'], name='auth_rolegroups_RoleID_fkey'),
sa.PrimaryKeyConstraint('RoleGroupID', name='auth_rolegroups_pkey')
)
op.create_table('msg_subscribers',
sa.Column('SubscriberID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('ThreadID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('UserID', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('Read', sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['ThreadID'], ['msg_threads.ThreadID'], name='msg_subscribers_ThreadID_fkey'),
sa.ForeignKeyConstraint(['UserID'], ['auth_users.UserID'], name='msg_subscribers_UserID_fkey'),
sa.PrimaryKeyConstraint('SubscriberID', name='msg_subscribers_pkey'),
sa.UniqueConstraint('ThreadID', 'UserID', name='msg_subscribers_ThreadID_UserID_key')
)
op.drop_table('user_roles')
op.drop_table('role_permissions')
op.drop_table('auth_permissions')
# ### end Alembic commands ###