"""change request foreign key to task order

Revision ID: 1c1394e496a7
Revises: 3dc8b7961bd1
Create Date: 2018-12-12 14:39:25.325640

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '1c1394e496a7'
down_revision = '3dc8b7961bd1'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column("requests", "task_order_id", new_column_name="legacy_task_order_id")
    op.drop_constraint('requests_task_order_id_fkey', 'requests', type_='foreignkey')
    op.create_foreign_key("requests_legacy_task_order_fkey", 'requests', 'legacy_task_orders', ['legacy_task_order_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column("requests", "legacy_task_order_id", new_column_name="task_order_id")
    op.drop_constraint("requests_legacy_task_order_fkey" 'requests', type_='foreignkey')
    op.create_foreign_key('requests_task_order_id_fkey', 'requests', 'legacy_task_orders', ['task_order_id'], ['id'])
    # ### end Alembic commands ###
