""" Upper indexes for subawards

Revision ID: 8290ddf8d51b
Revises: 15e6fb2c4e8d
Create Date: 2019-06-26 14:41:30.545424

"""

# revision identifiers, used by Alembic.
revision = '8290ddf8d51b'
down_revision = '15e6fb2c4e8d'
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_proc_contract_number_upper', 'fsrs_procurement', [text('UPPER(contract_number)')],
                    unique=False)
    op.create_index('ix_fsrs_proc_idv_ref_upper', 'fsrs_procurement', [text('UPPER(idv_reference_number)')],
                    unique=False)
    op.create_index('ix_fsrs_proc_contract_office_aid_upper', 'fsrs_procurement',
                    [text('UPPER(contracting_office_aid)')], unique=False)

    op.create_index('ix_fsrs_grant_fain_upper', 'fsrs_grant', [text('UPPER(fain)')], unique=False)

    op.create_index('ix_subaward_award_id_upper', 'subaward', [text('UPPER(award_id)')], unique=False)
    op.create_index('ix_subaward_parent_award_id_upper', 'subaward', [text('UPPER(parent_award_id)')], unique=False)
    op.create_index('ix_subaward_awarding_sub_tier_agency_c_upper', 'subaward',
                    [text('UPPER(awarding_sub_tier_agency_c)')], unique=False)

    op.create_index('ix_dap_piid_upper', 'detached_award_procurement', [text('UPPER(piid)')], unique=False)
    op.create_index('ix_dap_parent_award_id_upper', 'detached_award_procurement', [text('UPPER(parent_award_id)')],
                    unique=False)
    op.create_index('ix_dap_awarding_sub_tier_agency_c_upper', 'detached_award_procurement',
                    [text('UPPER(awarding_sub_tier_agency_c)')], unique=False)

    op.create_index('ix_pafa_fain_upper', 'published_award_financial_assistance', [text('UPPER(fain)')], unique=False)

    op.create_index('ix_ap_piid_upper', 'award_procurement', [text('UPPER(piid)')], unique=False)
    op.create_index('ix_ap_parent_award_id_upper', 'award_procurement', [text('UPPER(parent_award_id)')], unique=False)
    op.create_index('ix_ap_awarding_sub_tier_agency_c_upper', 'award_procurement',
                    [text('UPPER(awarding_sub_tier_agency_c)')], unique=False)

    op.create_index('ix_afa_fain_upper', 'award_financial_assistance', [text('UPPER(fain)')], unique=False)

    op.create_index('ix_af_piid_upper', 'award_financial', [text('UPPER(piid)')], unique=False)
    op.create_index('ix_af_parent_award_id_upper', 'award_financial', [text('UPPER(parent_award_id)')], unique=False)
    op.create_index('ix_af_fain_upper', 'award_financial', [text('UPPER(fain)')], unique=False)
    op.create_index('ix_af_uri_upper', 'award_financial', [text('UPPER(uri)')], unique=False)

    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_fsrs_proc_contract_number_upper', table_name='fsrs_procurement')
    op.drop_index('ix_fsrs_proc_idv_ref_upper', table_name='fsrs_procurement')
    op.drop_index('ix_fsrs_proc_contract_office_aid_upper', table_name='fsrs_procurement')

    op.drop_index('ix_fsrs_grant_fain_upper', table_name='fsrs_grant')

    op.drop_index('ix_subaward_award_id_upper', table_name='subaward')
    op.drop_index('ix_subaward_parent_award_id_upper', table_name='subaward')
    op.drop_index('ix_subaward_awarding_sub_tier_agency_c_upper', table_name='subaward')

    op.drop_index('ix_dap_piid_upper', table_name='detached_award_procurement')
    op.drop_index('ix_dap_parent_award_id_upper', table_name='detached_award_procurement')
    op.drop_index('ix_dap_awarding_sub_tier_agency_c_upper', table_name='detached_award_procurement')

    op.drop_index('ix_pafa_fain_upper', table_name='published_award_financial_assistance')

    op.drop_index('ix_ap_piid_upper', table_name='award_procurement')
    op.drop_index('ix_ap_parent_award_id_upper', table_name='award_procurement')
    op.drop_index('ix_ap_awarding_sub_tier_agency_c_upper', table_name='award_procurement')

    op.drop_index('ix_afa_fain_upper', table_name='award_financial_assistance')

    op.drop_index('ix_af_piid_upper', table_name='award_financial')
    op.drop_index('ix_af_parent_award_id_upper', table_name='award_financial')
    op.drop_index('ix_af_uri_upper', table_name='award_financial')
    op.drop_index('ix_af_fain_upper', table_name='award_financial')
    # ### end Alembic commands ###

