"""Convert federal_action_obligation to float

Revision ID: 6affb1acf439
Revises: d1f40bcf04b0
Create Date: 2016-12-28 17:13:14.632226

"""

# revision identifiers, used by Alembic.
revision = '6affb1acf439'
down_revision = 'd1f40bcf04b0'
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():
    # Alembic doesn't output the "USING" statement, which is required when
    # moving from string to numeric (not in reverse)
    op.execute("""
        ALTER TABLE award_financial_assistance
        ALTER COLUMN federal_action_obligation
        TYPE NUMERIC
        USING federal_action_obligation::numeric
    """)
    op.execute("""
        ALTER TABLE award_procurement
        ALTER COLUMN federal_action_obligation
        TYPE NUMERIC
        USING federal_action_obligation::numeric
    """)


def downgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('award_procurement', 'federal_action_obligation',
               existing_type=sa.Numeric(),
               type_=sa.TEXT(),
               existing_nullable=True)
    op.alter_column('award_financial_assistance', 'federal_action_obligation',
               existing_type=sa.Numeric(),
               type_=sa.TEXT(),
               existing_nullable=True)
    ### end Alembic commands ###

