"""Adding upper indexes to all UEI elements in FSRS tables

Revision ID: 56dee789619d
Revises: 589fcd5224fe
Create Date: 2022-02-15 12:59:04.449093

"""

# revision identifiers, used by Alembic.
revision = '56dee789619d'
down_revision = '589fcd5224fe'
branch_labels = None
depends_on = None

from alembic import op
from sqlalchemy import text


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index('ix_fsrs_grant_uei_number_upper', 'fsrs_grant', [text('UPPER(uei_number)')], unique=False)
    op.create_index('ix_fsrs_grant_parent_uei_upper', 'fsrs_grant', [text('UPPER(parent_uei)')], unique=False)
    op.create_index('ix_fsrs_subgrant_uei_number_upper', 'fsrs_subgrant', [text('UPPER(uei_number)')], unique=False)
    op.create_index('ix_fsrs_subgrant_parent_uei_upper', 'fsrs_subgrant', [text('UPPER(parent_uei)')], unique=False)
    op.create_index('ix_fsrs_proc_uei_number_upper', 'fsrs_procurement', [text('UPPER(uei_number)')], unique=False)
    op.create_index('ix_fsrs_proc_parent_uei_upper', 'fsrs_procurement', [text('UPPER(parent_uei)')], unique=False)
    op.create_index('ix_fsrs_subcont_uei_number_upper', 'fsrs_subcontract', [text('UPPER(uei_number)')], unique=False)
    op.create_index('ix_fsrs_subcont_parent_uei_upper', 'fsrs_subcontract', [text('UPPER(parent_uei)')], unique=False)
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_fsrs_subcont_parent_uei_upper', table_name='fsrs_subcontract')
    op.drop_index('ix_fsrs_subcont_uei_number_upper', table_name='fsrs_subcontract')
    op.drop_index('ix_fsrs_proc_parent_uei_upper', table_name='fsrs_procurement')
    op.drop_index('ix_fsrs_proc_uei_number_upper', table_name='fsrs_procurement')
    op.drop_index('ix_fsrs_subgrant_parent_uei_upper', table_name='fsrs_subgrant')
    op.drop_index('ix_fsrs_subgrant_uei_number_upper', table_name='fsrs_subgrant')
    op.drop_index('ix_fsrs_grant_parent_uei_upper', table_name='fsrs_grant')
    op.drop_index('ix_fsrs_grant_uei_number_upper', table_name='fsrs_grant')
    # ### end Alembic commands ###

