"""components

Revision ID: e7916fbdb2bd
Revises: 41eef43ae0f9
Create Date: 2023-06-26 17:26:35.601227

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'e7916fbdb2bd'
down_revision = '41eef43ae0f9'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_component_cmf_owner_assistants',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_component_cmf_owner_assistants_left_id'), 'cmf_component_cmf_owner_assistants', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_cmf_owner_assistants_parent_id'), 'cmf_component_cmf_owner_assistants', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_cmf_owner_assistants_right_id'), 'cmf_component_cmf_owner_assistants', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_cmf_owner_assistants_root_id'), 'cmf_component_cmf_owner_assistants', ['root_id'], unique=False)
    op.create_table('cmf_component_executors',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_component_executors_left_id'), 'cmf_component_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_executors_parent_id'), 'cmf_component_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_executors_right_id'), 'cmf_component_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_executors_root_id'), 'cmf_component_executors', ['root_id'], unique=False)
    op.create_table('cmf_component_local_links',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_component_local_links_left_id'), 'cmf_component_local_links', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_local_links_parent_id'), 'cmf_component_local_links', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_local_links_right_id'), 'cmf_component_local_links', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_local_links_root_id'), 'cmf_component_local_links', ['root_id'], unique=False)
    op.create_table('cmf_component_spectators',
    sa.Column('id', sa.String(length=128), nullable=False),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_component_spectators_left_id'), 'cmf_component_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_spectators_parent_id'), 'cmf_component_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_spectators_right_id'), 'cmf_component_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_spectators_root_id'), 'cmf_component_spectators', ['root_id'], unique=False)
    op.add_column('cmf_component', sa.Column('logic_prefix', sa.String(), nullable=True))
    op.add_column('cmf_component', sa.Column('ui_view_form', sa.String(length=32), nullable=False))
    op.add_column('cmf_component', sa.Column('parent_logic_prefix', sa.String(), nullable=True))
    op.add_column('cmf_component', sa.Column('status_modified_at', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('status_in_progress_start', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('status_in_progress_end', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('status_review_at', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('status_closed_at', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('no_control', sa.Boolean(), nullable=True))
    op.add_column('cmf_component', sa.Column('priority', sa.Integer(), nullable=False))
    op.add_column('cmf_component', sa.Column('mark', sa.String(length=32), nullable=True))
    op.add_column('cmf_component', sa.Column('alarm_date', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('deadline', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('plan_start_date', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('plan_end_date', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('period_next_date', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('cmf_component', sa.Column('period_interval', sa.String(length=32), nullable=True))
    op.add_column('cmf_component', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.add_column('cmf_component', sa.Column('is_penalty', sa.Boolean(), nullable=True))
    op.add_column('cmf_component', sa.Column('cache_status_type', sa.String(length=32), nullable=True))
    op.add_column('cmf_component', sa.Column('cache_fields', sa.TEXT(), nullable=True))
    op.add_column('cmf_component', sa.Column('approved', sa.Boolean(), nullable=False))
    op.add_column('cmf_component', sa.Column('perm_policy', sa.String(length=32), nullable=False))
    op.add_column('cmf_component', sa.Column('perm_policy_guest', sa.String(length=32), nullable=False))
    op.add_column('cmf_component', sa.Column('perm_policy_anonymous', sa.String(length=32), nullable=False))
    op.add_column('cmf_component', sa.Column('perm_policy_sharelink', sa.String(length=32), nullable=False))
    op.add_column('cmf_component', sa.Column('sharelink_hash', sa.String(length=32), nullable=True))
    op.add_column('cmf_component', sa.Column('workflow_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('default_task_workflow_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('logic_type_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('scheme_wf_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('cmf_owner_assistant_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('status_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('company_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('responsible_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('waiting_for_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('activity_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_component', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_component_activity_id'), 'cmf_component', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_alarm_date'), 'cmf_component', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_component_approved'), 'cmf_component', ['approved'], unique=False)
    op.create_index(op.f('ix_cmf_component_cache_status_opt_id'), 'cmf_component', ['cache_status_opt_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_cache_status_type'), 'cmf_component', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_component_cloned_from_id'), 'cmf_component', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_cmf_owner_assistant_id'), 'cmf_component', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_company_id'), 'cmf_component', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_default_task_workflow_id'), 'cmf_component', ['default_task_workflow_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_is_template'), 'cmf_component', ['is_template'], unique=False)
    op.create_index(op.f('ix_cmf_component_logic_prefix'), 'cmf_component', ['logic_prefix'], unique=False)
    op.create_index(op.f('ix_cmf_component_logic_type_id'), 'cmf_component', ['logic_type_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_parent_logic_prefix'), 'cmf_component', ['parent_logic_prefix'], unique=False)
    op.create_index(op.f('ix_cmf_component_responsible_id'), 'cmf_component', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_scheme_wf_id'), 'cmf_component', ['scheme_wf_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_status_id'), 'cmf_component', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_waiting_for_id'), 'cmf_component', ['waiting_for_id'], unique=False)
    op.create_index(op.f('ix_cmf_component_workflow_id'), 'cmf_component', ['workflow_id'], unique=False)
    op.create_foreign_key(None, 'cmf_component', 'cmf_status', ['status_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_activity', ['activity_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_company', ['company_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_workflow', ['default_task_workflow_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_workflow', ['workflow_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_logic_type', ['logic_type_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.create_foreign_key(None, 'cmf_component', 'cmf_scheme_wf', ['scheme_wf_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_constraint(None, 'cmf_component', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_component_workflow_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_waiting_for_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_status_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_scheme_wf_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_responsible_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_parent_logic_prefix'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_logic_type_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_logic_prefix'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_is_template'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_default_task_workflow_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_company_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_cmf_owner_assistant_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_cloned_from_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_cache_status_type'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_cache_status_opt_id'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_approved'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_alarm_date'), table_name='cmf_component')
    op.drop_index(op.f('ix_cmf_component_activity_id'), table_name='cmf_component')
    op.drop_column('cmf_component', 'cache_status_opt_id')
    op.drop_column('cmf_component', 'activity_id')
    op.drop_column('cmf_component', 'cloned_from_id')
    op.drop_column('cmf_component', 'waiting_for_id')
    op.drop_column('cmf_component', 'responsible_id')
    op.drop_column('cmf_component', 'company_id')
    op.drop_column('cmf_component', 'status_id')
    op.drop_column('cmf_component', 'cmf_owner_assistant_id')
    op.drop_column('cmf_component', 'scheme_wf_id')
    op.drop_column('cmf_component', 'logic_type_id')
    op.drop_column('cmf_component', 'default_task_workflow_id')
    op.drop_column('cmf_component', 'workflow_id')
    op.drop_column('cmf_component', 'sharelink_hash')
    op.drop_column('cmf_component', 'perm_policy_sharelink')
    op.drop_column('cmf_component', 'perm_policy_anonymous')
    op.drop_column('cmf_component', 'perm_policy_guest')
    op.drop_column('cmf_component', 'perm_policy')
    op.drop_column('cmf_component', 'approved')
    op.drop_column('cmf_component', 'cache_fields')
    op.drop_column('cmf_component', 'cache_status_type')
    op.drop_column('cmf_component', 'is_penalty')
    op.drop_column('cmf_component', 'is_template')
    op.drop_column('cmf_component', 'period_interval')
    op.drop_column('cmf_component', 'period_next_date')
    op.drop_column('cmf_component', 'plan_end_date')
    op.drop_column('cmf_component', 'plan_start_date')
    op.drop_column('cmf_component', 'deadline')
    op.drop_column('cmf_component', 'alarm_date')
    op.drop_column('cmf_component', 'mark')
    op.drop_column('cmf_component', 'priority')
    op.drop_column('cmf_component', 'no_control')
    op.drop_column('cmf_component', 'status_closed_at')
    op.drop_column('cmf_component', 'status_review_at')
    op.drop_column('cmf_component', 'status_in_progress_end')
    op.drop_column('cmf_component', 'status_in_progress_start')
    op.drop_column('cmf_component', 'status_modified_at')
    op.drop_column('cmf_component', 'parent_logic_prefix')
    op.drop_column('cmf_component', 'ui_view_form')
    op.drop_column('cmf_component', 'logic_prefix')
    op.drop_index(op.f('ix_cmf_component_spectators_root_id'), table_name='cmf_component_spectators')
    op.drop_index(op.f('ix_cmf_component_spectators_right_id'), table_name='cmf_component_spectators')
    op.drop_index(op.f('ix_cmf_component_spectators_parent_id'), table_name='cmf_component_spectators')
    op.drop_index(op.f('ix_cmf_component_spectators_left_id'), table_name='cmf_component_spectators')
    op.drop_table('cmf_component_spectators')
    op.drop_index(op.f('ix_cmf_component_local_links_root_id'), table_name='cmf_component_local_links')
    op.drop_index(op.f('ix_cmf_component_local_links_right_id'), table_name='cmf_component_local_links')
    op.drop_index(op.f('ix_cmf_component_local_links_parent_id'), table_name='cmf_component_local_links')
    op.drop_index(op.f('ix_cmf_component_local_links_left_id'), table_name='cmf_component_local_links')
    op.drop_table('cmf_component_local_links')
    op.drop_index(op.f('ix_cmf_component_executors_root_id'), table_name='cmf_component_executors')
    op.drop_index(op.f('ix_cmf_component_executors_right_id'), table_name='cmf_component_executors')
    op.drop_index(op.f('ix_cmf_component_executors_parent_id'), table_name='cmf_component_executors')
    op.drop_index(op.f('ix_cmf_component_executors_left_id'), table_name='cmf_component_executors')
    op.drop_table('cmf_component_executors')
    op.drop_index(op.f('ix_cmf_component_cmf_owner_assistants_root_id'), table_name='cmf_component_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_component_cmf_owner_assistants_right_id'), table_name='cmf_component_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_component_cmf_owner_assistants_parent_id'), table_name='cmf_component_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_component_cmf_owner_assistants_left_id'), table_name='cmf_component_cmf_owner_assistants')
    op.drop_table('cmf_component_cmf_owner_assistants')
    # ### end Alembic commands ###
