"""Task belongs to Flow, not FlowSession

Revision ID: 536821629959
Revises: 78c4d7a75ce5
Create Date: 2019-09-18 01:23:16.905220

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '536821629959'
down_revision = '78c4d7a75ce5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('task_name_flow_session_id_key', 'task', type_='unique')
    op.create_unique_constraint(None, 'task', ['name', 'flow_id'])
    op.drop_constraint('task_flow_session_id_fkey', 'task', type_='foreignkey')
    op.drop_column('task', 'flow_session_id')
    op.drop_constraint('task_run_task_id_flow_run_id_map_index_key', 'task_run', type_='unique')
    op.create_unique_constraint(None, 'task_run', ['task_id', 'flow_run_id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'task_run', type_='unique')
    op.create_unique_constraint('task_run_task_id_flow_run_id_map_index_key', 'task_run', ['task_id', 'flow_run_id', 'map_index'])
    op.add_column('task', sa.Column('flow_session_id', sa.INTEGER(), autoincrement=False, nullable=False))
    op.create_foreign_key('task_flow_session_id_fkey', 'task', 'flow_session', ['flow_session_id'], ['id'])
    op.drop_constraint(None, 'task', type_='unique')
    op.create_unique_constraint('task_name_flow_session_id_key', 'task', ['name', 'flow_session_id'])
    # ### end Alembic commands ###
