"""TaskQueue

Revision ID: 8b04d6a16e4b
Revises: de0a98fc480b
Create Date: 2023-01-30 12:04:33.955215

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8b04d6a16e4b'
down_revision = 'de0a98fc480b'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_task_queue',
    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('import_raw_json', sa.TEXT(), 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('is_public', sa.Boolean(), nullable=True),
    sa.Column('is_public_editable', sa.Boolean(), nullable=True),
    sa.Column('is_public_comments', sa.Boolean(), nullable=True),
    sa.Column('logic_prefix', sa.String(), nullable=True),
    sa.Column('ui_view_form', sa.String(length=32), nullable=False),
    sa.Column('parent_logic_prefix', sa.String(), nullable=True),
    sa.Column('status_modified_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('status_in_progress_start', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('status_in_progress_end', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('status_review_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('status_closed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('no_control', sa.Boolean(), nullable=True),
    sa.Column('priority', sa.Integer(), nullable=False),
    sa.Column('mark', sa.String(length=32), nullable=True),
    sa.Column('alarm_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('deadline', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('time_estimate', sa.Integer(), nullable=True),
    sa.Column('plan_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_end_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('period_next_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('period_interval', sa.String(length=32), nullable=True),
    sa.Column('is_template', sa.Boolean(), nullable=True),
    sa.Column('is_penalty', sa.Boolean(), nullable=True),
    sa.Column('cache_status_type', sa.String(length=32), nullable=True),
    sa.Column('cache_fields', sa.TEXT(), nullable=True),
    sa.Column('approved', sa.Boolean(), nullable=False),
    sa.Column('perm_policy', sa.String(length=32), nullable=False),
    sa.Column('perm_policy_guest', sa.String(length=32), nullable=False),
    sa.Column('perm_policy_anonymous', sa.String(length=32), nullable=False),
    sa.Column('perm_policy_sharelink', sa.String(length=32), nullable=False),
    sa.Column('sharelink_hash', sa.String(length=32), 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('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.Column('workflow_id', sa.String(length=64), nullable=True),
    sa.Column('default_task_workflow_id', sa.String(length=64), nullable=True),
    sa.Column('logic_type_id', sa.String(length=64), nullable=True),
    sa.Column('scheme_wf_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_assistant_id', sa.String(length=64), nullable=True),
    sa.Column('status_id', sa.String(length=64), nullable=True),
    sa.Column('company_id', sa.String(length=64), nullable=True),
    sa.Column('responsible_id', sa.String(length=64), nullable=True),
    sa.Column('waiting_for_id', sa.String(length=64), nullable=True),
    sa.Column('cloned_from_id', sa.String(length=64), nullable=True),
    sa.Column('activity_id', sa.String(length=64), nullable=True),
    sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True),
    sa.Column('task_filter_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['activity_id'], ['cmf_activity.id'], ),
    sa.ForeignKeyConstraint(['cache_status_opt_id'], ['cmf_status_opt.id'], ),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['company_id'], ['cmf_company.id'], ),
    sa.ForeignKeyConstraint(['default_task_workflow_id'], ['cmf_workflow.id'], ),
    sa.ForeignKeyConstraint(['logic_type_id'], ['cmf_logic_type.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['scheme_wf_id'], ['cmf_scheme_wf.id'], ),
    sa.ForeignKeyConstraint(['status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['task_filter_id'], ['cmf_task_filter.id'], ),
    sa.ForeignKeyConstraint(['workflow_id'], ['cmf_workflow.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_task_queue_activity_id'), 'cmf_task_queue', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_alarm_date'), 'cmf_task_queue', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_approved'), 'cmf_task_queue', ['approved'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cache_status_opt_id'), 'cmf_task_queue', ['cache_status_opt_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cache_status_type'), 'cmf_task_queue', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cloned_from_id'), 'cmf_task_queue', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_author_id'), 'cmf_task_queue', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_created_at'), 'cmf_task_queue', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_deleted'), 'cmf_task_queue', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_import_id'), 'cmf_task_queue', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_locked_at'), 'cmf_task_queue', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_locked_by_id'), 'cmf_task_queue', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_modified_at'), 'cmf_task_queue', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_modified_by_id'), 'cmf_task_queue', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_owner_assistant_id'), 'cmf_task_queue', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_owner_id'), 'cmf_task_queue', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_version'), 'cmf_task_queue', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_viewed_at'), 'cmf_task_queue', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_code'), 'cmf_task_queue', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_task_queue_company_id'), 'cmf_task_queue', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_default_task_workflow_id'), 'cmf_task_queue', ['default_task_workflow_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_is_template'), 'cmf_task_queue', ['is_template'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_logic_prefix'), 'cmf_task_queue', ['logic_prefix'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_logic_type_id'), 'cmf_task_queue', ['logic_type_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_name'), 'cmf_task_queue', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_orderno'), 'cmf_task_queue', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_parent_id'), 'cmf_task_queue', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_parent_logic_prefix'), 'cmf_task_queue', ['parent_logic_prefix'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_perm_acl_id'), 'cmf_task_queue', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_perm_parent_id'), 'cmf_task_queue', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_responsible_id'), 'cmf_task_queue', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_scheme_wf_id'), 'cmf_task_queue', ['scheme_wf_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_status_id'), 'cmf_task_queue', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_task_filter_id'), 'cmf_task_queue', ['task_filter_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_tree_parent_id'), 'cmf_task_queue', ['tree_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_waiting_for_id'), 'cmf_task_queue', ['waiting_for_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_workflow_id'), 'cmf_task_queue', ['workflow_id'], unique=False)
    op.create_table('cmf_task_queue_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_task_queue_cmf_owner_assistants_left_id'), 'cmf_task_queue_cmf_owner_assistants', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_parent_id'), 'cmf_task_queue_cmf_owner_assistants', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_right_id'), 'cmf_task_queue_cmf_owner_assistants', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_root_id'), 'cmf_task_queue_cmf_owner_assistants', ['root_id'], unique=False)
    op.create_table('cmf_task_queue_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_task_queue_executors_left_id'), 'cmf_task_queue_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_executors_parent_id'), 'cmf_task_queue_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_executors_right_id'), 'cmf_task_queue_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_executors_root_id'), 'cmf_task_queue_executors', ['root_id'], unique=False)
    op.create_table('cmf_task_queue_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_task_queue_spectators_left_id'), 'cmf_task_queue_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_spectators_parent_id'), 'cmf_task_queue_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_spectators_right_id'), 'cmf_task_queue_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_queue_spectators_root_id'), 'cmf_task_queue_spectators', ['root_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_cmf_task_queue_spectators_root_id'), table_name='cmf_task_queue_spectators')
    op.drop_index(op.f('ix_cmf_task_queue_spectators_right_id'), table_name='cmf_task_queue_spectators')
    op.drop_index(op.f('ix_cmf_task_queue_spectators_parent_id'), table_name='cmf_task_queue_spectators')
    op.drop_index(op.f('ix_cmf_task_queue_spectators_left_id'), table_name='cmf_task_queue_spectators')
    op.drop_table('cmf_task_queue_spectators')
    op.drop_index(op.f('ix_cmf_task_queue_executors_root_id'), table_name='cmf_task_queue_executors')
    op.drop_index(op.f('ix_cmf_task_queue_executors_right_id'), table_name='cmf_task_queue_executors')
    op.drop_index(op.f('ix_cmf_task_queue_executors_parent_id'), table_name='cmf_task_queue_executors')
    op.drop_index(op.f('ix_cmf_task_queue_executors_left_id'), table_name='cmf_task_queue_executors')
    op.drop_table('cmf_task_queue_executors')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_root_id'), table_name='cmf_task_queue_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_right_id'), table_name='cmf_task_queue_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_parent_id'), table_name='cmf_task_queue_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_owner_assistants_left_id'), table_name='cmf_task_queue_cmf_owner_assistants')
    op.drop_table('cmf_task_queue_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_task_queue_workflow_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_waiting_for_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_tree_parent_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_task_filter_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_status_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_scheme_wf_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_responsible_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_perm_parent_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_perm_acl_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_parent_logic_prefix'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_parent_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_orderno'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_name'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_logic_type_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_logic_prefix'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_is_template'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_default_task_workflow_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_company_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_code'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_viewed_at'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_version'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_owner_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_owner_assistant_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_modified_by_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_modified_at'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_locked_by_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_locked_at'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_import_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_deleted'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_created_at'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cmf_author_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cloned_from_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cache_status_type'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_cache_status_opt_id'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_approved'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_alarm_date'), table_name='cmf_task_queue')
    op.drop_index(op.f('ix_cmf_task_queue_activity_id'), table_name='cmf_task_queue')
    op.drop_table('cmf_task_queue')
    # ### end Alembic commands ###
