"""Alter and add many columns in DetachedAwardProcurement and AwardProcurement

Revision ID: d45dde2ba15b
Revises: 001758a1ab82
Create Date: 2018-03-09 14:08:13.058669

"""

# revision identifiers, used by Alembic.
revision = 'd45dde2ba15b'
down_revision = '001758a1ab82'
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.execute("ALTER TABLE award_procurement RENAME COLUMN walsh_healey_act TO materials_supplies_article")
    op.execute("ALTER TABLE award_procurement RENAME COLUMN service_contract_act TO labor_standards")
    op.execute("ALTER TABLE award_procurement RENAME COLUMN davis_bacon_act TO construction_wage_rate_req")
    op.execute("ALTER TABLE award_procurement RENAME COLUMN government_furnished_equip TO government_furnished_prope")
    op.add_column('award_procurement', sa.Column('cage_code', sa.Text(), nullable=True))
    op.add_column('award_procurement', sa.Column('inherently_government_func', sa.Text(), nullable=True))
    op.add_column('award_procurement', sa.Column('organizational_type', sa.Text(), nullable=True))
    op.add_column('award_procurement', sa.Column('number_of_employees', sa.Text(), nullable=True))
    op.add_column('award_procurement', sa.Column('annual_revenue', sa.Text(), nullable=True))
    op.add_column('award_procurement', sa.Column('total_obligated_amount', sa.Text(), nullable=True))

    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN walsh_healey_act TO materials_supplies_article")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN walsh_healey_act_descrip TO materials_supplies_descrip")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN service_contract_act TO labor_standards")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN service_contract_act_desc TO labor_standards_descrip")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN davis_bacon_act TO construction_wage_rate_req")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN davis_bacon_act_descrip TO construction_wage_rat_desc")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN government_furnished_equip TO government_furnished_prope")
    op.add_column('detached_award_procurement', sa.Column('cage_code', sa.Text(), nullable=True))
    op.add_column('detached_award_procurement', sa.Column('inherently_government_func', sa.Text(), nullable=True))
    op.add_column('detached_award_procurement', sa.Column('organizational_type', sa.Text(), nullable=True))
    ### end Alembic commands ###


def downgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("ALTER TABLE award_procurement RENAME COLUMN materials_supplies_article TO walsh_healey_act")
    op.execute("ALTER TABLE award_procurement RENAME COLUMN labor_standards TO service_contract_act")
    op.execute("ALTER TABLE award_procurement RENAME COLUMN construction_wage_rate_req TO davis_bacon_act")
    op.execute("ALTER TABLE award_procurement RENAME COLUMN government_furnished_prope TO government_furnished_equip")
    op.drop_column('award_procurement', 'cage_code')
    op.drop_column('award_procurement', 'inherently_government_func')
    op.drop_column('award_procurement', 'organizational_type')
    op.drop_column('award_procurement', 'number_of_employees')
    op.drop_column('award_procurement', 'annual_revenue')
    op.drop_column('award_procurement', 'total_obligated_amount')

    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN materials_supplies_article TO walsh_healey_act")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN materials_supplies_descrip TO walsh_healey_act_descrip")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN labor_standards TO service_contract_act")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN labor_standards_descrip TO service_contract_act_desc")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN construction_wage_rate_req TO davis_bacon_act")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN construction_wage_rat_desc TO davis_bacon_act_descrip")
    op.execute("ALTER TABLE detached_award_procurement RENAME COLUMN government_furnished_prope TO government_furnished_equip")
    op.drop_column('detached_award_procurement', 'cage_code')
    op.drop_column('detached_award_procurement', 'inherently_government_func')
    op.drop_column('detached_award_procurement', 'organizational_type')
    ### end Alembic commands ###

