"""add_gantt_task

Revision ID: aba217b23144
Revises: 73dc72cac582
Create Date: 2022-11-13 20:06:17.980006

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'aba217b23144'
down_revision = '73dc72cac582'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_gantt_baseline',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('import_original', sa.Boolean(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('is_favorite', sa.Boolean(), nullable=True),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=True),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=True),
    sa.Column('tree_hidden', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=True),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=True),
    sa.Column('perm_inherit', sa.Boolean(), nullable=True),
    sa.Column('perm_parent_owner_id', sa.String(length=64), nullable=True),
    sa.Column('perm_inherit_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_effective_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=True),
    sa.Column('active_baseline', sa.Boolean(), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_assistant_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('perm_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_parent_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_author_id'), 'cmf_gantt_baseline', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_created_at'), 'cmf_gantt_baseline', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_deleted'), 'cmf_gantt_baseline', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_import_id'), 'cmf_gantt_baseline', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_locked_at'), 'cmf_gantt_baseline', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_locked_by_id'), 'cmf_gantt_baseline', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_modified_at'), 'cmf_gantt_baseline', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_modified_by_id'), 'cmf_gantt_baseline', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_owner_assistant_id'), 'cmf_gantt_baseline', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_owner_id'), 'cmf_gantt_baseline', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_version'), 'cmf_gantt_baseline', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_cmf_viewed_at'), 'cmf_gantt_baseline', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_code'), 'cmf_gantt_baseline', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_gantt_baseline_name'), 'cmf_gantt_baseline', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_orderno'), 'cmf_gantt_baseline', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_parent_id'), 'cmf_gantt_baseline', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_perm_acl_id'), 'cmf_gantt_baseline', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_perm_parent_id'), 'cmf_gantt_baseline', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_baseline_tree_parent_id'), 'cmf_gantt_baseline', ['tree_parent_id'], unique=False)
    op.create_table('cmf_gantt_task',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('const_resource', sa.Boolean(), nullable=False),
    sa.Column('constrain_start_type', sa.String(length=32), nullable=False),
    sa.Column('constrain_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('constrain_finish_type', sa.String(length=32), nullable=True),
    sa.Column('constrain_finish_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('const_cost', sa.Boolean(), nullable=False),
    sa.Column('agregat_cost', sa.Numeric(precision=14, scale=2), nullable=False),
    sa.Column('sched_cost', sa.Numeric(precision=14, scale=2), nullable=False),
    sa.Column('perform_cost', sa.Numeric(precision=14, scale=2), nullable=False),
    sa.Column('actual_cost', sa.Numeric(precision=14, scale=2), nullable=False),
    sa.Column('const_duration', sa.Boolean(), nullable=False),
    sa.Column('agregat_duration', sa.Integer(), nullable=True),
    sa.Column('sched_duration', sa.Integer(), nullable=True),
    sa.Column('perform_duration', sa.Integer(), nullable=True),
    sa.Column('actual_duration', sa.Integer(), nullable=True),
    sa.Column('const_duration_24h', sa.Boolean(), nullable=False),
    sa.Column('agregat_work', sa.Integer(), nullable=True),
    sa.Column('sched_work', sa.Integer(), nullable=True),
    sa.Column('perform_work', sa.Integer(), nullable=True),
    sa.Column('actual_work', sa.Integer(), nullable=True),
    sa.Column('perform_complete', sa.Integer(), nullable=True),
    sa.Column('actual_complete', sa.Integer(), nullable=True),
    sa.Column('duration_is_estimated', sa.Boolean(), nullable=False),
    sa.Column('actual_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('actual_finish_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('actual_stop_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('actual_resume_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('constrain_slack', sa.Integer(), nullable=True),
    sa.Column('constrain_slack_pct', sa.Integer(), nullable=True),
    sa.Column('is_milestone', sa.Boolean(), nullable=False),
    sa.Column('is_critical_path', sa.Boolean(), nullable=False),
    sa.Column('is_included_project', sa.Boolean(), nullable=False),
    sa.Column('included_project_readonly', sa.Boolean(), nullable=False),
    sa.Column('is_marked', sa.Boolean(), nullable=False),
    sa.Column('const_can_split', sa.Boolean(), nullable=False),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_assistant_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=False),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('project_id', sa.String(length=64), nullable=False),
    sa.Column('task_id', sa.String(length=64), nullable=False),
    sa.ForeignKeyConstraint(['parent_id'], ['cmf_gantt_baseline.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.ForeignKeyConstraint(['task_id'], ['cmf_task.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_gantt_task_cmf_author_id'), 'cmf_gantt_task', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_created_at'), 'cmf_gantt_task', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_deleted'), 'cmf_gantt_task', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_locked_at'), 'cmf_gantt_task', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_locked_by_id'), 'cmf_gantt_task', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_modified_at'), 'cmf_gantt_task', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_modified_by_id'), 'cmf_gantt_task', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_owner_assistant_id'), 'cmf_gantt_task', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_owner_id'), 'cmf_gantt_task', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_version'), 'cmf_gantt_task', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_cmf_viewed_at'), 'cmf_gantt_task', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_constrain_finish_date'), 'cmf_gantt_task', ['constrain_finish_date'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_constrain_finish_type'), 'cmf_gantt_task', ['constrain_finish_type'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_constrain_slack'), 'cmf_gantt_task', ['constrain_slack'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_constrain_start_date'), 'cmf_gantt_task', ['constrain_start_date'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_constrain_start_type'), 'cmf_gantt_task', ['constrain_start_type'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_parent_id'), 'cmf_gantt_task', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_project_id'), 'cmf_gantt_task', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_gantt_task_task_id'), 'cmf_gantt_task', ['task_id'], unique=False)
    op.add_column('cmf_task', sa.Column('bp_gantt_task_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_task', sa.Column('op_gantt_task_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_task', sa.Column('outline_number', sa.String(length=32), nullable=True))
    op.create_index(op.f('ix_cmf_task_bp_gantt_task_id'), 'cmf_task', ['bp_gantt_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_op_gantt_task_id'), 'cmf_task', ['op_gantt_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_outline_number'), 'cmf_task', ['outline_number'], unique=False)
    op.create_foreign_key(None, 'cmf_task', 'cmf_gantt_task', ['op_gantt_task_id'], ['id'])
    op.create_foreign_key(None, 'cmf_task', 'cmf_gantt_task', ['bp_gantt_task_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_task', type_='foreignkey')
    op.drop_constraint(None, 'cmf_task', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_task_outline_number'), table_name='cmf_task')
    op.drop_index(op.f('ix_cmf_task_op_gantt_task_id'), table_name='cmf_task')
    op.drop_index(op.f('ix_cmf_task_bp_gantt_task_id'), table_name='cmf_task')
    op.drop_column('cmf_task', 'outline_number')
    op.drop_column('cmf_task', 'op_gantt_task_id')
    op.drop_column('cmf_task', 'bp_gantt_task_id')
    op.drop_index(op.f('ix_cmf_gantt_task_task_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_project_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_parent_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_constrain_start_type'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_constrain_start_date'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_constrain_slack'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_constrain_finish_type'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_constrain_finish_date'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_viewed_at'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_version'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_owner_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_owner_assistant_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_modified_by_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_modified_at'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_locked_by_id'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_locked_at'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_deleted'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_created_at'), table_name='cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_task_cmf_author_id'), table_name='cmf_gantt_task')
    op.drop_table('cmf_gantt_task')
    op.drop_index(op.f('ix_cmf_gantt_baseline_tree_parent_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_perm_parent_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_perm_acl_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_parent_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_orderno'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_name'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_code'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_viewed_at'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_version'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_owner_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_owner_assistant_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_modified_by_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_modified_at'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_locked_by_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_locked_at'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_import_id'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_deleted'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_created_at'), table_name='cmf_gantt_baseline')
    op.drop_index(op.f('ix_cmf_gantt_baseline_cmf_author_id'), table_name='cmf_gantt_baseline')
    op.drop_table('cmf_gantt_baseline')
    # ### end Alembic commands ###
