"""Add unique_award_key to AwardProcurement, AwardFinancialAssistance, CertifiedAwardProcurement, and CertifiedAwardFinancialAssistance

Revision ID: 3fd9a578c9c5
Revises: 0225d53e520a
Create Date: 2020-01-23 14:39:59.527010

"""

# revision identifiers, used by Alembic.
revision = '3fd9a578c9c5'
down_revision = '0225d53e520a'
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! ###
    op.add_column('award_financial_assistance', sa.Column('unique_award_key', sa.Text(), nullable=True))
    op.add_column('award_procurement', sa.Column('unique_award_key', sa.Text(), nullable=True))
    op.add_column('certified_award_financial_assistance', sa.Column('unique_award_key', sa.Text(), nullable=True))
    op.add_column('certified_award_procurement', sa.Column('unique_award_key', sa.Text(), nullable=True))
    op.create_index('ix_af_pan_upper', 'award_financial', [sa.text('UPPER(program_activity_name)')], unique=False)
    op.create_index('ix_oc_pa_pan_upper', 'object_class_program_activity', [sa.text('UPPER(program_activity_name)')], unique=False)
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_oc_pa_pan_upper', table_name='object_class_program_activity')
    op.drop_index('ix_af_pan_upper', table_name='award_financial')
    op.drop_column('certified_award_procurement', 'unique_award_key')
    op.drop_column('certified_award_financial_assistance', 'unique_award_key')
    op.drop_column('award_procurement', 'unique_award_key')
    op.drop_column('award_financial_assistance', 'unique_award_key')
    # ### end Alembic commands ###

