9c9f0dfdd6
replaced my custom ValidationErro with FastAPI HTTPException Fixed?: Attendance Employee Attendance
47 lines
2.3 KiB
Python
47 lines
2.3 KiB
Python
"""Rename Service Charge to Incentive
|
|
|
|
Revision ID: 5498fc4bf58d
|
|
Revises: eed0b382c287
|
|
Create Date: 2020-05-12 16:39:12.157447
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.sql import table, column
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '5498fc4bf58d'
|
|
down_revision = 'eed0b382c287'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
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.rename_table('service_charges', 'incentives')
|
|
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'])
|
|
|
|
role = table('auth_roles', column('name', sa.String))
|
|
op.execute(role.update().where(role.c.name == op.inline_literal('Service Charge')).values({'name': op.inline_literal('Incentive')}))
|
|
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')}))
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_constraint('fk_incentives_journal_id_journals', 'incentives', type_='foreignkey')
|
|
op.drop_constraint('fk_incentives_voucher_id_vouchers', 'incentives', type_='foreignkey')
|
|
op.rename_table('incentives', 'service_charges')
|
|
op.create_foreign_key('service_charges_journal_id_fkey', 'service_charges', 'journals', ['journal_id'], ['journals.id'])
|
|
op.create_foreign_key('service_charges_voucher_id_fkey', 'service_charges', 'vouchers', ['voucher_id'], ['vouchers.id'])
|
|
|
|
role = table('auth_roles', column('name', sa.String))
|
|
op.execute(role.update().where(role.c.name == op.inline_literal('Incentive')).values({'name': op.inline_literal('Service Charge')}))
|
|
account = table('accounts', column('name', sa.String))
|
|
op.execute(account.update().where(account.c.name == op.inline_literal('Incentives')).values({'name': op.inline_literal('Service Charges')}))
|
|
# ### end Alembic commands ###
|