"""checklist

Revision ID: 2143f65c116c
Revises: cfdc5890b076
Create Date: 2025-02-25 08:59:30.311788

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2143f65c116c'
down_revision = 'cfdc5890b076'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_checklist',
    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=False),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('cmf_archived', sa.Boolean(), nullable=False),
    sa.Column('is_favorite', sa.Boolean(), nullable=False),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=False),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=False),
    sa.Column('tree_hidden', sa.Boolean(), nullable=False),
    sa.Column('sl_owner_lock', sa.Boolean(), nullable=False),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=False),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=False),
    sa.Column('perm_inherit', sa.Boolean(), nullable=False),
    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_security_level_allowed_ids_cache', sa.TEXT(), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=False),
    sa.Column('perm_encrypt_help', sa.String(length=256), nullable=True),
    sa.Column('checklist_items_count', sa.Integer(), nullable=True),
    sa.Column('checklist_items_done_count', sa.Integer(), 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=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('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('root_parent_id', sa.String(length=64), nullable=True),
    sa.Column('project_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(['parent_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_checklist_cmf_author_id'), 'cmf_checklist', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_created_at'), 'cmf_checklist', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_deleted'), 'cmf_checklist', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_import_id'), 'cmf_checklist', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_locked_at'), 'cmf_checklist', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_locked_by_id'), 'cmf_checklist', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_modified_at'), 'cmf_checklist', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_modified_by_id'), 'cmf_checklist', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_owner_id'), 'cmf_checklist', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_version'), 'cmf_checklist', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_cmf_viewed_at'), 'cmf_checklist', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_code'), 'cmf_checklist', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_checklist_name'), 'cmf_checklist', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_orderno'), 'cmf_checklist', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_parent_id'), 'cmf_checklist', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_perm_acl_id'), 'cmf_checklist', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_perm_parent_id'), 'cmf_checklist', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_project_id'), 'cmf_checklist', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_root_parent_id'), 'cmf_checklist', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_tree_parent_id'), 'cmf_checklist', ['tree_parent_id'], unique=False)
    op.create_table('cmf_checklist_item',
    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=False),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('cmf_archived', sa.Boolean(), nullable=False),
    sa.Column('is_favorite', sa.Boolean(), nullable=False),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=False),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=False),
    sa.Column('tree_hidden', sa.Boolean(), nullable=False),
    sa.Column('sl_owner_lock', sa.Boolean(), nullable=False),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=False),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=False),
    sa.Column('perm_inherit', sa.Boolean(), nullable=False),
    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_security_level_allowed_ids_cache', sa.TEXT(), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=False),
    sa.Column('perm_encrypt_help', sa.String(length=256), nullable=True),
    sa.Column('status', sa.String(length=32), 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('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('root_parent_id', sa.String(length=64), nullable=True),
    sa.Column('project_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('cache_task_id', sa.String(length=64), nullable=True),
    sa.Column('converted_to_task_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['cache_task_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['converted_to_task_id'], ['cmf_task.id'], ),
    sa.ForeignKeyConstraint(['parent_id'], ['cmf_checklist.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_checklist_item_cache_task_id'), 'cmf_checklist_item', ['cache_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_author_id'), 'cmf_checklist_item', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_created_at'), 'cmf_checklist_item', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_deleted'), 'cmf_checklist_item', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_import_id'), 'cmf_checklist_item', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_locked_at'), 'cmf_checklist_item', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_locked_by_id'), 'cmf_checklist_item', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_modified_at'), 'cmf_checklist_item', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_modified_by_id'), 'cmf_checklist_item', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_owner_id'), 'cmf_checklist_item', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_version'), 'cmf_checklist_item', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_cmf_viewed_at'), 'cmf_checklist_item', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_code'), 'cmf_checklist_item', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_checklist_item_converted_to_task_id'), 'cmf_checklist_item', ['converted_to_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_name'), 'cmf_checklist_item', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_parent_id'), 'cmf_checklist_item', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_perm_acl_id'), 'cmf_checklist_item', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_perm_parent_id'), 'cmf_checklist_item', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_project_id'), 'cmf_checklist_item', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_root_parent_id'), 'cmf_checklist_item', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_item_tree_parent_id'), 'cmf_checklist_item', ['tree_parent_id'], unique=False)
    op.create_table('cmf_checklist_template',
    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=False),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('cmf_archived', sa.Boolean(), nullable=False),
    sa.Column('is_favorite', sa.Boolean(), nullable=False),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=False),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=False),
    sa.Column('tree_hidden', sa.Boolean(), nullable=False),
    sa.Column('sl_owner_lock', sa.Boolean(), nullable=False),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=False),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=False),
    sa.Column('perm_inherit', sa.Boolean(), nullable=False),
    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_security_level_allowed_ids_cache', sa.TEXT(), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=False),
    sa.Column('perm_encrypt_help', sa.String(length=256), nullable=True),
    sa.Column('view_scope', sa.String(length=32), nullable=False),
    sa.Column('cmf_author_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('root_parent_id', sa.String(length=64), nullable=True),
    sa.Column('project_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.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_checklist_template_cmf_author_id'), 'cmf_checklist_template', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_created_at'), 'cmf_checklist_template', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_deleted'), 'cmf_checklist_template', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_import_id'), 'cmf_checklist_template', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_locked_at'), 'cmf_checklist_template', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_locked_by_id'), 'cmf_checklist_template', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_modified_at'), 'cmf_checklist_template', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_modified_by_id'), 'cmf_checklist_template', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_version'), 'cmf_checklist_template', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_viewed_at'), 'cmf_checklist_template', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_code'), 'cmf_checklist_template', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_checklist_template_name'), 'cmf_checklist_template', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_orderno'), 'cmf_checklist_template', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_parent_id'), 'cmf_checklist_template', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_perm_acl_id'), 'cmf_checklist_template', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_perm_parent_id'), 'cmf_checklist_template', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_project_id'), 'cmf_checklist_template', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_root_parent_id'), 'cmf_checklist_template', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_tree_parent_id'), 'cmf_checklist_template', ['tree_parent_id'], unique=False)
    op.create_table('cmf_checklist_template_cmf_logic_type',
    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.ForeignKeyConstraint(['left_id'], ['cmf_checklist_template.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_logic_type.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_checklist_template_cmf_logic_type_left_id'), 'cmf_checklist_template_cmf_logic_type', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_logic_type_parent_id'), 'cmf_checklist_template_cmf_logic_type', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_logic_type_right_id'), 'cmf_checklist_template_cmf_logic_type', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_logic_type_root_id'), 'cmf_checklist_template_cmf_logic_type', ['root_id'], unique=False)
    op.create_table('cmf_checklist_template_cmf_owner',
    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_checklist_template_cmf_owner_left_id'), 'cmf_checklist_template_cmf_owner', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_owner_parent_id'), 'cmf_checklist_template_cmf_owner', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_owner_right_id'), 'cmf_checklist_template_cmf_owner', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_cmf_owner_root_id'), 'cmf_checklist_template_cmf_owner', ['root_id'], unique=False)
    op.create_table('cmf_checklist_template_item',
    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=False),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('cmf_archived', sa.Boolean(), nullable=False),
    sa.Column('is_favorite', sa.Boolean(), nullable=False),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=False),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=False),
    sa.Column('tree_hidden', sa.Boolean(), nullable=False),
    sa.Column('sl_owner_lock', sa.Boolean(), nullable=False),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=False),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=False),
    sa.Column('perm_inherit', sa.Boolean(), nullable=False),
    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_security_level_allowed_ids_cache', sa.TEXT(), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=False),
    sa.Column('perm_encrypt_help', sa.String(length=256), 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('root_parent_id', sa.String(length=64), nullable=True),
    sa.Column('project_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(['parent_id'], ['cmf_checklist_template.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_author_id'), 'cmf_checklist_template_item', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_created_at'), 'cmf_checklist_template_item', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_deleted'), 'cmf_checklist_template_item', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_import_id'), 'cmf_checklist_template_item', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_locked_at'), 'cmf_checklist_template_item', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_locked_by_id'), 'cmf_checklist_template_item', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_modified_at'), 'cmf_checklist_template_item', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_modified_by_id'), 'cmf_checklist_template_item', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_owner_id'), 'cmf_checklist_template_item', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_version'), 'cmf_checklist_template_item', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_cmf_viewed_at'), 'cmf_checklist_template_item', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_code'), 'cmf_checklist_template_item', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_checklist_template_item_name'), 'cmf_checklist_template_item', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_parent_id'), 'cmf_checklist_template_item', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_perm_acl_id'), 'cmf_checklist_template_item', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_perm_parent_id'), 'cmf_checklist_template_item', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_project_id'), 'cmf_checklist_template_item', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_root_parent_id'), 'cmf_checklist_template_item', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_checklist_template_item_tree_parent_id'), 'cmf_checklist_template_item', ['tree_parent_id'], unique=False)
    op.add_column('cmf_project', sa.Column('sl_deny_closing_task_before_closing_checklists', sa.Boolean(), nullable=False, server_default="false"))
    op.add_column('cmf_task', sa.Column('checklists_items_count', sa.Integer(), nullable=True))
    op.add_column('cmf_task', sa.Column('checklists_items_done_count', sa.Integer(), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('cmf_task', 'checklists_items_done_count')
    op.drop_column('cmf_task', 'checklists_items_count')
    op.drop_column('cmf_project', 'sl_deny_closing_task_before_closing_checklists')
    op.drop_index(op.f('ix_cmf_checklist_template_item_tree_parent_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_root_parent_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_project_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_perm_parent_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_perm_acl_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_parent_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_name'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_code'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_viewed_at'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_version'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_owner_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_modified_by_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_modified_at'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_locked_by_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_locked_at'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_import_id'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_deleted'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_created_at'), table_name='cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_item_cmf_author_id'), table_name='cmf_checklist_template_item')
    op.drop_table('cmf_checklist_template_item')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_owner_root_id'), table_name='cmf_checklist_template_cmf_owner')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_owner_right_id'), table_name='cmf_checklist_template_cmf_owner')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_owner_parent_id'), table_name='cmf_checklist_template_cmf_owner')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_owner_left_id'), table_name='cmf_checklist_template_cmf_owner')
    op.drop_table('cmf_checklist_template_cmf_owner')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_logic_type_root_id'), table_name='cmf_checklist_template_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_logic_type_right_id'), table_name='cmf_checklist_template_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_logic_type_parent_id'), table_name='cmf_checklist_template_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_logic_type_left_id'), table_name='cmf_checklist_template_cmf_logic_type')
    op.drop_table('cmf_checklist_template_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_checklist_template_tree_parent_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_root_parent_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_project_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_perm_parent_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_perm_acl_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_parent_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_orderno'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_name'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_code'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_viewed_at'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_version'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_modified_by_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_modified_at'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_locked_by_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_locked_at'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_import_id'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_deleted'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_created_at'), table_name='cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_template_cmf_author_id'), table_name='cmf_checklist_template')
    op.drop_table('cmf_checklist_template')
    op.drop_index(op.f('ix_cmf_checklist_item_tree_parent_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_root_parent_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_project_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_perm_parent_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_perm_acl_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_parent_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_name'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_converted_to_task_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_code'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_viewed_at'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_version'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_owner_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_modified_by_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_modified_at'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_locked_by_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_locked_at'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_import_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_deleted'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_created_at'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cmf_author_id'), table_name='cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_item_cache_task_id'), table_name='cmf_checklist_item')
    op.drop_table('cmf_checklist_item')
    op.drop_index(op.f('ix_cmf_checklist_tree_parent_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_root_parent_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_project_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_perm_parent_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_perm_acl_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_parent_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_orderno'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_name'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_code'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_viewed_at'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_version'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_owner_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_modified_by_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_modified_at'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_locked_by_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_locked_at'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_import_id'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_deleted'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_created_at'), table_name='cmf_checklist')
    op.drop_index(op.f('ix_cmf_checklist_cmf_author_id'), table_name='cmf_checklist')
    op.drop_table('cmf_checklist')
    # ### end Alembic commands ###
