"""Gantt1

Revision ID: 338111063ea7
Revises: f26b4114a24e
Create Date: 2022-11-15 22:55:53.696025

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '338111063ea7'
down_revision = 'f26b4114a24e'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_gantt_baseline', sa.Column('is_operate', sa.Boolean(), nullable=True))
    op.create_foreign_key(None, 'cmf_gantt_baseline', 'cmf_task', ['parent_id'], ['id'])
    op.add_column('cmf_gantt_task', sa.Column('gantt_project_id', sa.String(length=64), nullable=False))
    op.create_index(op.f('ix_cmf_gantt_task_gantt_project_id'), 'cmf_gantt_task', ['gantt_project_id'], unique=False)
    op.create_foreign_key(None, 'cmf_gantt_task', 'cmf_task', ['gantt_project_id'], ['id'])
    op.add_column('cmf_project', sa.Column('main_gantt_project_id', sa.String(length=64), nullable=True))
    op.drop_index('ix_cmf_project_op_gantt_baseline_id', table_name='cmf_project')
    op.create_index(op.f('ix_cmf_project_main_gantt_project_id'), 'cmf_project', ['main_gantt_project_id'], unique=False)
    op.drop_constraint('cmf_project_op_gantt_baseline_id_fkey', 'cmf_project', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_project', 'cmf_task', ['main_gantt_project_id'], ['id'])
    op.drop_column('cmf_project', 'op_gantt_baseline_id')
    op.add_column('cmf_task', sa.Column('gantt_project_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_task_gantt_project_id'), 'cmf_task', ['gantt_project_id'], unique=False)
    op.create_foreign_key(None, 'cmf_task', 'cmf_task', ['gantt_project_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_task', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_task_gantt_project_id'), table_name='cmf_task')
    op.drop_column('cmf_task', 'gantt_project_id')
    op.add_column('cmf_project', sa.Column('op_gantt_baseline_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_project', type_='foreignkey')
    op.create_foreign_key('cmf_project_op_gantt_baseline_id_fkey', 'cmf_project', 'cmf_gantt_baseline', ['op_gantt_baseline_id'], ['id'])
    op.drop_index(op.f('ix_cmf_project_main_gantt_project_id'), table_name='cmf_project')
    op.create_index('ix_cmf_project_op_gantt_baseline_id', 'cmf_project', ['op_gantt_baseline_id'], unique=False)
    op.drop_column('cmf_project', 'main_gantt_project_id')
    op.drop_constraint(None, 'cmf_gantt_task', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_gantt_task_gantt_project_id'), table_name='cmf_gantt_task')
    op.drop_column('cmf_gantt_task', 'gantt_project_id')
    op.drop_constraint(None, 'cmf_gantt_baseline', type_='foreignkey')
    op.drop_column('cmf_gantt_baseline', 'is_operate')
    # ### end Alembic commands ###
