"""Adding uei and ultimate_parent_uei to fsrs and subaward tables

Revision ID: b1a4cd095f48
Revises: 0172b4703e8c
Create Date: 2021-09-16 10:48:17.544130

"""

# revision identifiers, used by Alembic.
revision = 'b1a4cd095f48'
down_revision = '0172b4703e8c'
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('fsrs_grant', sa.Column('uei', sa.String(), nullable=True))
    op.add_column('fsrs_grant', sa.Column('ultimate_parent_uei', sa.String(), nullable=True))
    op.add_column('fsrs_procurement', sa.Column('uei', sa.String(), nullable=True))
    op.add_column('fsrs_procurement', sa.Column('ultimate_parent_uei', sa.String(), nullable=True))
    op.add_column('fsrs_subcontract', sa.Column('uei', sa.String(), nullable=True))
    op.add_column('fsrs_subcontract', sa.Column('ultimate_parent_uei', sa.String(), nullable=True))
    op.add_column('fsrs_subgrant', sa.Column('uei', sa.String(), nullable=True))
    op.add_column('fsrs_subgrant', sa.Column('ultimate_parent_uei', sa.String(), nullable=True))
    op.add_column('subaward', sa.Column('awardee_or_recipient_uei', sa.Text(), nullable=True))
    op.add_column('subaward', sa.Column('sub_awardee_or_recipient_uei', sa.Text(), nullable=True))
    op.add_column('subaward', sa.Column('sub_ultimate_parent_uei', sa.Text(), nullable=True))
    op.add_column('subaward', sa.Column('ultimate_parent_uei', sa.Text(), nullable=True))
    op.create_index(op.f('ix_subaward_awardee_or_recipient_uei'), 'subaward', ['awardee_or_recipient_uei'], unique=False)
    op.create_index(op.f('ix_subaward_sub_awardee_or_recipient_uei'), 'subaward', ['sub_awardee_or_recipient_uei'], unique=False)
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_subaward_sub_awardee_or_recipient_uei'), table_name='subaward')
    op.drop_index(op.f('ix_subaward_awardee_or_recipient_uei'), table_name='subaward')
    op.drop_column('subaward', 'ultimate_parent_uei')
    op.drop_column('subaward', 'sub_ultimate_parent_uei')
    op.drop_column('subaward', 'sub_awardee_or_recipient_uei')
    op.drop_column('subaward', 'awardee_or_recipient_uei')
    op.drop_column('fsrs_subgrant', 'ultimate_parent_uei')
    op.drop_column('fsrs_subgrant', 'uei')
    op.drop_column('fsrs_subcontract', 'ultimate_parent_uei')
    op.drop_column('fsrs_subcontract', 'uei')
    op.drop_column('fsrs_procurement', 'ultimate_parent_uei')
    op.drop_column('fsrs_procurement', 'uei')
    op.drop_column('fsrs_grant', 'ultimate_parent_uei')
    op.drop_column('fsrs_grant', 'uei')
    # ### end Alembic commands ###

