"""GanttBaseline refactoring

Revision ID: 0aab48a80d84
Revises: 9d602e9e196e
Create Date: 2023-06-06 17:20:28.301175

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0aab48a80d84'
down_revision = '9d602e9e196e'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_gantt_baseline', sa.Column('view_scope', sa.String(length=32), nullable=False, server_default='common'))
    op.drop_constraint('cmf_gantt_baseline_parent_id_fkey', 'cmf_gantt_baseline', type_='foreignkey')
    op.execute('update cmf_gantt_baseline set parent_id=null')
    op.create_foreign_key(None, 'cmf_gantt_baseline', 'cmf_project', ['parent_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_gantt_baseline', type_='foreignkey')
    op.create_foreign_key('cmf_gantt_baseline_parent_id_fkey', 'cmf_gantt_baseline', 'cmf_task', ['parent_id'], ['id'])
    op.drop_column('cmf_gantt_baseline', 'view_scope')
    # ### end Alembic commands ###
