"""Rename detached_ and published_award_financial_assistance tables to fabs and published_fabs

Revision ID: 3ff22fa8cb2e
Revises: 7896e714ba8e
Create Date: 2022-05-09 10:43:31.250658

"""

# revision identifiers, used by Alembic.
revision = '3ff22fa8cb2e'
down_revision = '7896e714ba8e'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


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! ###

    # detached_award_financial_assistance rename
    op.execute("ALTER TABLE detached_award_financial_assistance RENAME TO fabs")
    op.execute("ALTER TABLE fabs RENAME COLUMN detached_award_financial_assistance_id TO fabs_id")
    op.execute("ALTER SEQUENCE detached_award_financial_assi_detached_award_financial_assi_seq RENAME TO fabs_fabs_id_seq")
    op.execute("ALTER TABLE fabs RENAME CONSTRAINT fk_detached_award_financial_assistance_submission_id TO fk_fabs_submission_id")
    op.execute("ALTER INDEX detached_award_financial_assistance_pkey RENAME TO fabs_pkey")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_job_id RENAME TO ix_fabs_job_id")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_submission_id RENAME TO ix_fabs_submission_id")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_afa_generated_unique RENAME TO ix_fabs_afa_generated_unique")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_action_date RENAME TO ix_fabs_action_date")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_action_type RENAME TO ix_fabs_action_type")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_assistance_type RENAME TO ix_fabs_assistance_type")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_awardee_or_recip_0d94 RENAME TO ix_fabs_awardee_or_recipient_uniqu")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_awarding_sub_tie_97a6 RENAME TO ix_fabs_awarding_sub_tier_agency_c")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_cfda_number RENAME TO ix_fabs_cfda_number")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_fain RENAME TO ix_fabs_fain")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_funding_office_code RENAME TO ix_fabs_funding_office_code")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_funding_sub_tier_a60f RENAME TO ix_fabs_funding_sub_tier_agency_co")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_period_of_perfor_3e1b RENAME TO ix_fabs_period_of_performance_curr")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_period_of_perfor_c799 RENAME TO ix_fabs_period_of_performance_star")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_place_of_perform_e8a7 RENAME TO ix_fabs_place_of_perform_country_c")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_place_of_perform_d7bb RENAME TO ix_fabs_place_of_performance_code")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_record_type RENAME TO ix_fabs_record_type")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_row_number RENAME TO ix_fabs_row_number")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_uri RENAME TO ix_fabs_uri")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_legal_entity_zip5 RENAME TO ix_fabs_legal_entity_zip5")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_legal_entity_zip_last4 RENAME TO ix_fabs_legal_entity_zip_last4")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_legal_entity_con_56e1 RENAME TO ix_fabs_legal_entity_congressional")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_correction_delet_6a5f RENAME TO ix_fabs_correction_delete_indicatr")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_unique_award_key RENAME TO ix_fabs_unique_award_key")
    op.execute("ALTER INDEX ix_dafa_afa_generated_unique_upper RENAME TO ix_fabs_afa_generated_unique_upper")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_uei RENAME TO ix_fabs_uei")
    op.execute("ALTER INDEX ix_dafa_uei_upper RENAME TO ix_fabs_uei_upper")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_federal_action_o_7c33 RENAME TO ix_fabs_federal_action_obligation")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_funding_opportun_b0f1 RENAME TO ix_fabs_funding_opportunity_goals")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_funding_opportun_e924 RENAME TO ix_fabs_funding_opportunity_number")
    op.execute("ALTER INDEX ix_detached_award_financial_assistance_indirect_federal_sharing RENAME TO ix_fabs_indirect_federal_sharing")

    # published_award_financial_assistance rename
    op.execute("ALTER TABLE published_award_financial_assistance RENAME TO published_fabs")
    op.execute("ALTER TABLE published_fabs RENAME COLUMN published_award_financial_assistance_id TO published_fabs_id")
    op.execute("ALTER SEQUENCE published_award_financial_ass_published_award_financial_ass_seq RENAME TO published_fabs_published_fabs_id_seq")
    op.execute("ALTER INDEX published_award_financial_assistance_pkey RENAME TO published_fabs_pkey")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_afa_generated_unique RENAME TO ix_published_fabs_afa_generated_unique")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_action_date RENAME TO ix_published_fabs_action_date")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_action_type RENAME TO ix_published_fabs_action_type")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_assistance_type RENAME TO ix_published_fabs_assistance_type")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_awardee_or_reci_d8ae RENAME TO ix_published_fabs_awardee_or_recipient_uniqu")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_awarding_agency_code RENAME TO ix_published_fabs_awarding_agency_code")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_awarding_sub_ti_f74b RENAME TO ix_published_fabs_awarding_sub_tier_agency_c")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_cfda_number RENAME TO ix_published_fabs_cfda_number")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_fain RENAME TO ix_published_fabs_fain")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_funding_agency_code RENAME TO ix_published_fabs_funding_agency_code")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_funding_office_code RENAME TO ix_published_fabs_funding_office_code")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_funding_sub_tie_96ff RENAME TO ix_published_fabs_funding_sub_tier_agency_co")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_period_of_perfo_06bf RENAME TO ix_published_fabs_period_of_perfomance_curr")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_period_of_perfo_177f RENAME TO ix_published_fabs_period_of_perfomance_star")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_place_of_perfor_f216 RENAME TO ix_published_fabs_place_of_perform_country_c")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_place_of_perfor_13d0 RENAME TO ix_published_fabs_place_of_performance_congr")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_record_type RENAME TO ix_published_fabs_record_type")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_uri RENAME TO ix_published_fabs_uri")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_submission_id RENAME TO ix_published_fabs_submission_id")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_is_active RENAME TO ix_published_fabs_is_active")
    op.execute("ALTER INDEX ix_fabs_cast_action_date_as_date RENAME TO ix_published_fabs_cast_action_date_as_date")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_created_at RENAME TO ix_published_fabs_created_at")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_correction_dele_2358 RENAME TO ix_published_fabs_correction_delete_indicatr")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_unique_award_key RENAME TO ix_published_fabs_unique_award_key")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_uei RENAME TO ix_published_fabs_uei")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_ultimate_parent_c2ed RENAME TO ix_published_fabs_ultimate_parent_unique_ide")
    op.execute("ALTER INDEX ix_published_award_financial_assistance_ultimate_parent_uei RENAME TO ix_published_fabs_ultimate_parent_uei")
    op.execute("ALTER INDEX ix_pafa_fain_awarding_sub_tier_is_active RENAME TO ix_published_fabs_fain_awarding_sub_tier_is_active")
    op.execute("ALTER INDEX ix_pafa_uri_awarding_sub_tier_is_active RENAME TO ix_published_fabs_uri_awarding_sub_tier_is_active")
    op.execute("ALTER INDEX ix_pafa_afa_generated_unique_upper RENAME TO ix_published_fabs_afa_generated_unique_upper")
    op.execute("ALTER INDEX ix_pafa_fain_upper RENAME TO ix_published_fabs_fain_upper")
    op.execute("ALTER INDEX ix_pafa_uri_upper RENAME TO ix_published_fabs_uri_upper")
    op.execute("ALTER INDEX ix_pafa_awarding_subtier_c_upper RENAME TO ix_published_fabs_awarding_subtier_c_upper")
    op.execute("ALTER INDEX ix_pafa_fain_awarding_subtier_upper RENAME TO ix_published_fabs_fain_awarding_subtier_upper")
    op.execute("ALTER INDEX ix_pafa_uri_awarding_subtier_upper RENAME TO ix_published_fabs_uri_awarding_subtier_upper")
    op.execute("ALTER INDEX ix_pafa_uei_upper RENAME TO ix_published_fabs_uei_upper")
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    # fabs rename
    op.execute("ALTER INDEX ix_fabs_indirect_federal_sharing RENAME TO ix_detached_award_financial_assistance_indirect_federal_sharing")
    op.execute("ALTER INDEX ix_fabs_funding_opportunity_number RENAME TO ix_detached_award_financial_assistance_funding_opportun_e924")
    op.execute("ALTER INDEX ix_fabs_funding_opportunity_goals RENAME TO ix_detached_award_financial_assistance_funding_opportun_b0f1")
    op.execute("ALTER INDEX ix_fabs_federal_action_obligation RENAME TO ix_detached_award_financial_assistance_federal_action_o_7c33")
    op.execute("ALTER INDEX ix_fabs_uei_upper RENAME TO ix_dafa_uei_upper")
    op.execute("ALTER INDEX ix_fabs_uei RENAME TO ix_detached_award_financial_assistance_uei")
    op.execute("ALTER INDEX ix_fabs_afa_generated_unique_upper RENAME TO ix_dafa_afa_generated_unique_upper")
    op.execute("ALTER INDEX ix_fabs_unique_award_key RENAME TO ix_detached_award_financial_assistance_unique_award_key")
    op.execute("ALTER INDEX ix_fabs_correction_delete_indicatr RENAME TO ix_detached_award_financial_assistance_correction_delet_6a5f")
    op.execute("ALTER INDEX ix_fabs_legal_entity_congressional RENAME TO ix_detached_award_financial_assistance_legal_entity_con_56e1")
    op.execute("ALTER INDEX ix_fabs_legal_entity_zip_last4 RENAME TO ix_detached_award_financial_assistance_legal_entity_zip_last4")
    op.execute("ALTER INDEX ix_fabs_legal_entity_zip5 RENAME TO ix_detached_award_financial_assistance_legal_entity_zip5")
    op.execute("ALTER INDEX ix_fabs_uri RENAME TO ix_detached_award_financial_assistance_uri")
    op.execute("ALTER INDEX ix_fabs_row_number RENAME TO ix_detached_award_financial_assistance_row_number")
    op.execute("ALTER INDEX ix_fabs_record_type RENAME TO ix_detached_award_financial_assistance_record_type")
    op.execute("ALTER INDEX ix_fabs_place_of_performance_code RENAME TO ix_detached_award_financial_assistance_place_of_perform_d7bb")
    op.execute("ALTER INDEX ix_fabs_place_of_perform_country_c RENAME TO ix_detached_award_financial_assistance_place_of_perform_e8a7")
    op.execute("ALTER INDEX ix_fabs_period_of_performance_star RENAME TO ix_detached_award_financial_assistance_period_of_perfor_c799")
    op.execute("ALTER INDEX ix_fabs_period_of_performance_curr RENAME TO ix_detached_award_financial_assistance_period_of_perfor_3e1b")
    op.execute("ALTER INDEX ix_fabs_funding_sub_tier_agency_co RENAME TO ix_detached_award_financial_assistance_funding_sub_tier_a60f")
    op.execute("ALTER INDEX ix_fabs_funding_office_code RENAME TO ix_detached_award_financial_assistance_funding_office_code")
    op.execute("ALTER INDEX ix_fabs_fain RENAME TO ix_detached_award_financial_assistance_fain")
    op.execute("ALTER INDEX ix_fabs_cfda_number RENAME TO ix_detached_award_financial_assistance_cfda_number")
    op.execute("ALTER INDEX ix_fabs_awarding_sub_tier_agency_c RENAME TO ix_detached_award_financial_assistance_awarding_sub_tie_97a6")
    op.execute("ALTER INDEX ix_fabs_awardee_or_recipient_uniqu RENAME TO ix_detached_award_financial_assistance_awardee_or_recip_0d94")
    op.execute("ALTER INDEX ix_fabs_assistance_type RENAME TO ix_detached_award_financial_assistance_assistance_type")
    op.execute("ALTER INDEX ix_fabs_action_type RENAME TO ix_detached_award_financial_assistance_action_type")
    op.execute("ALTER INDEX ix_fabs_action_date RENAME TO ix_detached_award_financial_assistance_action_date")
    op.execute("ALTER INDEX ix_fabs_afa_generated_unique RENAME TO ix_detached_award_financial_assistance_afa_generated_unique")
    op.execute("ALTER INDEX ix_fabs_submission_id RENAME TO ix_detached_award_financial_assistance_submission_id")
    op.execute("ALTER INDEX ix_fabs_job_id RENAME TO ix_detached_award_financial_assistance_job_id")
    op.execute("ALTER INDEX fabs_pkey RENAME TO detached_award_financial_assistance_pkey")
    op.execute("ALTER TABLE fabs RENAME CONSTRAINT fk_fabs_submission_id TO fk_detached_award_financial_assistance_submission_id")
    op.execute("ALTER SEQUENCE fabs_fabs_id_seq RENAME TO detached_award_financial_assi_detached_award_financial_assi_seq")
    op.execute("ALTER TABLE fabs RENAME COLUMN fabs_id TO detached_award_financial_assistance_id")
    op.execute("ALTER TABLE fabs RENAME TO detached_award_financial_assistance")

    # published_fabs rename
    op.execute("ALTER INDEX ix_published_fabs_uei_upper RENAME TO ix_pafa_uei_upper")
    op.execute("ALTER INDEX ix_published_fabs_uri_awarding_subtier_upper RENAME TO ix_pafa_uri_awarding_subtier_upper")
    op.execute("ALTER INDEX ix_published_fabs_fain_awarding_subtier_upper RENAME TO ix_pafa_fain_awarding_subtier_upper")
    op.execute("ALTER INDEX ix_published_fabs_awarding_subtier_c_upper RENAME TO ix_pafa_awarding_subtier_c_upper")
    op.execute("ALTER INDEX ix_published_fabs_uri_upper RENAME TO ix_pafa_uri_upper")
    op.execute("ALTER INDEX ix_published_fabs_fain_upper RENAME TO ix_pafa_fain_upper")
    op.execute("ALTER INDEX ix_published_fabs_afa_generated_unique_upper RENAME TO ix_pafa_afa_generated_unique_upper")
    op.execute("ALTER INDEX ix_published_fabs_uri_awarding_sub_tier_is_active RENAME TO ix_pafa_uri_awarding_sub_tier_is_active")
    op.execute("ALTER INDEX ix_published_fabs_fain_awarding_sub_tier_is_active RENAME TO ix_pafa_fain_awarding_sub_tier_is_active")
    op.execute("ALTER INDEX ix_published_fabs_ultimate_parent_uei RENAME TO ix_published_award_financial_assistance_ultimate_parent_uei")
    op.execute("ALTER INDEX ix_published_fabs_ultimate_parent_unique_ide RENAME TO ix_published_award_financial_assistance_ultimate_parent_c2ed")
    op.execute("ALTER INDEX ix_published_fabs_uei RENAME TO ix_published_award_financial_assistance_uei")
    op.execute("ALTER INDEX ix_published_fabs_unique_award_key RENAME TO ix_published_award_financial_assistance_unique_award_key")
    op.execute("ALTER INDEX ix_published_fabs_correction_delete_indicatr RENAME TO ix_published_award_financial_assistance_correction_dele_2358")
    op.execute("ALTER INDEX ix_published_fabs_created_at RENAME TO ix_published_award_financial_assistance_created_at")
    op.execute("ALTER INDEX ix_published_fabs_cast_action_date_as_date RENAME TO ix_fabs_cast_action_date_as_date")
    op.execute("ALTER INDEX ix_published_fabs_is_active RENAME TO ix_published_award_financial_assistance_is_active")
    op.execute("ALTER INDEX ix_published_fabs_submission_id RENAME TO ix_published_award_financial_assistance_submission_id")
    op.execute("ALTER INDEX ix_published_fabs_uri RENAME TO ix_published_award_financial_assistance_uri")
    op.execute("ALTER INDEX ix_published_fabs_record_type RENAME TO ix_published_award_financial_assistance_record_type")
    op.execute("ALTER INDEX ix_published_fabs_place_of_performance_congr RENAME TO ix_published_award_financial_assistance_place_of_perfor_13d0")
    op.execute("ALTER INDEX ix_published_fabs_place_of_perform_country_c RENAME TO ix_published_award_financial_assistance_place_of_perfor_f216")
    op.execute("ALTER INDEX ix_published_fabs_period_of_perfomance_star RENAME TO ix_published_award_financial_assistance_period_of_perfo_177f")
    op.execute("ALTER INDEX ix_published_fabs_period_of_perfomance_curr RENAME TO ix_published_award_financial_assistance_period_of_perfo_06bf")
    op.execute("ALTER INDEX ix_published_fabs_funding_sub_tier_agency_co RENAME TO ix_published_award_financial_assistance_funding_sub_tie_96ff")
    op.execute("ALTER INDEX ix_published_fabs_funding_office_code RENAME TO ix_published_award_financial_assistance_funding_office_code")
    op.execute("ALTER INDEX ix_published_fabs_funding_agency_code RENAME TO ix_published_award_financial_assistance_funding_agency_code")
    op.execute("ALTER INDEX ix_published_fabs_fain RENAME TO ix_published_award_financial_assistance_fain")
    op.execute("ALTER INDEX ix_published_fabs_cfda_number RENAME TO ix_published_award_financial_assistance_cfda_number")
    op.execute("ALTER INDEX ix_published_fabs_awarding_sub_tier_agency_c RENAME TO ix_published_award_financial_assistance_awarding_sub_ti_f74b")
    op.execute("ALTER INDEX ix_published_fabs_awarding_agency_code RENAME TO ix_published_award_financial_assistance_awarding_agency_code")
    op.execute("ALTER INDEX ix_published_fabs_awardee_or_recipient_uniqu RENAME TO ix_published_award_financial_assistance_awardee_or_reci_d8ae")
    op.execute("ALTER INDEX ix_published_fabs_assistance_type RENAME TO ix_published_award_financial_assistance_assistance_type")
    op.execute("ALTER INDEX ix_published_fabs_action_type RENAME TO ix_published_award_financial_assistance_action_type")
    op.execute("ALTER INDEX ix_published_fabs_action_date RENAME TO ix_published_award_financial_assistance_action_date")
    op.execute("ALTER INDEX ix_published_fabs_afa_generated_unique RENAME TO ix_published_award_financial_assistance_afa_generated_unique")
    op.execute("ALTER INDEX published_fabs_pkey RENAME TO published_award_financial_assistance_pkey")
    op.execute("ALTER SEQUENCE published_fabs_published_fabs_id_seq RENAME TO published_award_financial_ass_published_award_financial_ass_seq")
    op.execute("ALTER TABLE published_fabs RENAME COLUMN published_fabs_id TO published_award_financial_assistance_id")
    op.execute("ALTER TABLE published_fabs RENAME TO published_award_financial_assistance")
    # ### end Alembic commands ###

