"""add_mailbox2

Revision ID: d35561c630e7
Revises: 6b541ef32465
Create Date: 2023-03-15 08:58:23.255344

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd35561c630e7'
down_revision = '6b541ef32465'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_mailbox2',
                    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('email', sa.String(length=64), nullable=True),
                    sa.Column('login', sa.String(length=64), nullable=True),
                    sa.Column('password', sa.String(length=256), nullable=True),
                    sa.Column('imap_server', sa.String(length=256), nullable=True),
                    sa.Column('imap_port', sa.String(length=32), nullable=True),
                    sa.Column('imap_crypt', sa.String(length=32), nullable=True),
                    sa.Column('smtp_server', sa.String(length=256), nullable=True),
                    sa.Column('smtp_port', sa.String(length=32), nullable=True),
                    sa.Column('smtp_crypt', sa.String(length=32), nullable=True),
                    sa.Column('maildir_path', sa.String(length=256), nullable=True),
                    sa.Column('load_from_date', sa.DATE(), nullable=True),
                    sa.Column('last_sync', sa.TIMESTAMP(timezone=True), nullable=True),
                    sa.Column('sync_interval', sa.Integer(), nullable=False),
                    sa.Column('sync_error_log', sa.TEXT(), 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('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_mailbox2_cmf_author_id'), 'cmf_mailbox2', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_created_at'), 'cmf_mailbox2', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_deleted'), 'cmf_mailbox2', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_import_id'), 'cmf_mailbox2', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_locked_at'), 'cmf_mailbox2', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_locked_by_id'), 'cmf_mailbox2', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_modified_at'), 'cmf_mailbox2', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_modified_by_id'), 'cmf_mailbox2', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_owner_id'), 'cmf_mailbox2', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_version'), 'cmf_mailbox2', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_cmf_viewed_at'), 'cmf_mailbox2', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_code'), 'cmf_mailbox2', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_mailbox2_name'), 'cmf_mailbox2', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_orderno'), 'cmf_mailbox2', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_parent_id'), 'cmf_mailbox2', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_perm_acl_id'), 'cmf_mailbox2', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_perm_parent_id'), 'cmf_mailbox2', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_root_parent_id'), 'cmf_mailbox2', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_tree_parent_id'), 'cmf_mailbox2', ['tree_parent_id'], unique=False)
    op.create_table('cmf_mailbox2_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_mailbox2_executors_left_id'), 'cmf_mailbox2_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_executors_parent_id'), 'cmf_mailbox2_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_executors_right_id'), 'cmf_mailbox2_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox2_executors_root_id'), 'cmf_mailbox2_executors', ['root_id'], unique=False)
    op.create_table('cmf_mailbox_folder',
    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('name_raw', sa.String(length=256), nullable=False),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('last_sync', sa.TIMESTAMP(timezone=True), 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=False),
    sa.Column('root_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(['parent_id'], ['cmf_mailbox2.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_author_id'), 'cmf_mailbox_folder', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_created_at'), 'cmf_mailbox_folder', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_deleted'), 'cmf_mailbox_folder', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_import_id'), 'cmf_mailbox_folder', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_locked_at'), 'cmf_mailbox_folder', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_locked_by_id'), 'cmf_mailbox_folder', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_modified_at'), 'cmf_mailbox_folder', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_modified_by_id'), 'cmf_mailbox_folder', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_owner_id'), 'cmf_mailbox_folder', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_version'), 'cmf_mailbox_folder', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_cmf_viewed_at'), 'cmf_mailbox_folder', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_code'), 'cmf_mailbox_folder', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_mailbox_folder_name'), 'cmf_mailbox_folder', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_name_raw'), 'cmf_mailbox_folder', ['name_raw'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_orderno'), 'cmf_mailbox_folder', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_parent_id'), 'cmf_mailbox_folder', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_perm_acl_id'), 'cmf_mailbox_folder', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_perm_parent_id'), 'cmf_mailbox_folder', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_root_parent_id'), 'cmf_mailbox_folder', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mailbox_folder_tree_parent_id'), 'cmf_mailbox_folder', ['tree_parent_id'], unique=False)
    op.add_column('cmf_mail', sa.Column('mail_from', sa.String(length=256), nullable=True))
    op.add_column('cmf_mail', sa.Column('mail_from_name', sa.String(length=256), nullable=True))
    op.add_column('cmf_mail', sa.Column('mail_to', sa.String(length=256), nullable=True))
    op.add_column('cmf_mail', sa.Column('mail_to_json', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('is_readed', sa.Boolean(), nullable=False, server_default="false"))
    op.add_column('cmf_mail', sa.Column('text_html', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('text_search', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('mail_headers', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('imap_uid', sa.String(length=256), nullable=True))
    op.add_column('cmf_mail', sa.Column('message_id', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('in_reply_to_raw', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('references_raw', sa.TEXT(), nullable=True))
    op.add_column('cmf_mail', sa.Column('mailbox_folder_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_mail', sa.Column('in_reply_to_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_mail', sa.Column('handle_obj_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_mail_handle_obj_id'), 'cmf_mail', ['handle_obj_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_in_reply_to_id'), 'cmf_mail', ['in_reply_to_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_mailbox_folder_id'), 'cmf_mail', ['mailbox_folder_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_message_id'), 'cmf_mail', ['message_id'], unique=False)
    op.create_foreign_key(None, 'cmf_mail', 'cmf_mail', ['in_reply_to_id'], ['id'])
    op.create_foreign_key(None, 'cmf_mail', 'cmf_mailbox_folder', ['mailbox_folder_id'], ['id'])
    op.create_table('cmf_mail_handler',
    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('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('handler_type', sa.String(length=32), nullable=False),
    sa.Column('create_user', 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('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('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('mailbox_id', sa.String(length=64), nullable=False),
    sa.Column('obj_logic_type_id', sa.String(length=64), nullable=True),
    sa.Column('obj_author_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(['mailbox_id'], ['cmf_mailbox2.id'], ),
    sa.ForeignKeyConstraint(['obj_author_id'], ['cmf_person.id'], ),
    sa.ForeignKeyConstraint(['obj_logic_type_id'], ['cmf_logic_type.id'], ),
    sa.ForeignKeyConstraint(['parent_id'], ['cmf_project.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(['workflow_id'], ['cmf_workflow.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_mail_handler_activity_id'), 'cmf_mail_handler', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_alarm_date'), 'cmf_mail_handler', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_approved'), 'cmf_mail_handler', ['approved'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cache_status_opt_id'), 'cmf_mail_handler', ['cache_status_opt_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cache_status_type'), 'cmf_mail_handler', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cloned_from_id'), 'cmf_mail_handler', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_author_id'), 'cmf_mail_handler', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_created_at'), 'cmf_mail_handler', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_deleted'), 'cmf_mail_handler', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_import_id'), 'cmf_mail_handler', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_locked_at'), 'cmf_mail_handler', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_locked_by_id'), 'cmf_mail_handler', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_modified_at'), 'cmf_mail_handler', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_modified_by_id'), 'cmf_mail_handler', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_owner_assistant_id'), 'cmf_mail_handler', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_owner_id'), 'cmf_mail_handler', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_version'), 'cmf_mail_handler', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_viewed_at'), 'cmf_mail_handler', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_code'), 'cmf_mail_handler', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_mail_handler_company_id'), 'cmf_mail_handler', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_default_task_workflow_id'), 'cmf_mail_handler', ['default_task_workflow_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_is_template'), 'cmf_mail_handler', ['is_template'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_logic_prefix'), 'cmf_mail_handler', ['logic_prefix'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_logic_type_id'), 'cmf_mail_handler', ['logic_type_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_mailbox_id'), 'cmf_mail_handler', ['mailbox_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_name'), 'cmf_mail_handler', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_obj_author_id'), 'cmf_mail_handler', ['obj_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_obj_logic_type_id'), 'cmf_mail_handler', ['obj_logic_type_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_orderno'), 'cmf_mail_handler', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_parent_id'), 'cmf_mail_handler', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_parent_logic_prefix'), 'cmf_mail_handler', ['parent_logic_prefix'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_perm_acl_id'), 'cmf_mail_handler', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_perm_parent_id'), 'cmf_mail_handler', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_responsible_id'), 'cmf_mail_handler', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_root_parent_id'), 'cmf_mail_handler', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_scheme_wf_id'), 'cmf_mail_handler', ['scheme_wf_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_status_id'), 'cmf_mail_handler', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_tree_parent_id'), 'cmf_mail_handler', ['tree_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_waiting_for_id'), 'cmf_mail_handler', ['waiting_for_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_workflow_id'), 'cmf_mail_handler', ['workflow_id'], unique=False)
    op.create_table('cmf_mail_handler_cmf_mailbox_folder',
    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_mail_handler.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_mailbox_folder.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_left_id'), 'cmf_mail_handler_cmf_mailbox_folder', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_parent_id'), 'cmf_mail_handler_cmf_mailbox_folder', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_right_id'), 'cmf_mail_handler_cmf_mailbox_folder', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_root_id'), 'cmf_mail_handler_cmf_mailbox_folder', ['root_id'], unique=False)
    op.create_table('cmf_mail_handler_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_mail_handler_cmf_owner_assistants_left_id'), 'cmf_mail_handler_cmf_owner_assistants', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_parent_id'), 'cmf_mail_handler_cmf_owner_assistants', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_right_id'), 'cmf_mail_handler_cmf_owner_assistants', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_root_id'), 'cmf_mail_handler_cmf_owner_assistants', ['root_id'], unique=False)
    op.create_table('cmf_mail_handler_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_mail_handler_executors_left_id'), 'cmf_mail_handler_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_executors_parent_id'), 'cmf_mail_handler_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_executors_right_id'), 'cmf_mail_handler_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_executors_root_id'), 'cmf_mail_handler_executors', ['root_id'], unique=False)
    op.create_table('cmf_mail_handler_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_mail_handler_local_links_left_id'), 'cmf_mail_handler_local_links', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_local_links_parent_id'), 'cmf_mail_handler_local_links', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_local_links_right_id'), 'cmf_mail_handler_local_links', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_local_links_root_id'), 'cmf_mail_handler_local_links', ['root_id'], unique=False)
    op.create_table('cmf_mail_handler_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_mail_handler_spectators_left_id'), 'cmf_mail_handler_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_spectators_parent_id'), 'cmf_mail_handler_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_spectators_right_id'), 'cmf_mail_handler_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_handler_spectators_root_id'), 'cmf_mail_handler_spectators', ['root_id'], unique=False)
    op.create_table('cmf_mail_references',
    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_mail_references_left_id'), 'cmf_mail_references', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_references_parent_id'), 'cmf_mail_references', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_references_right_id'), 'cmf_mail_references', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_references_root_id'), 'cmf_mail_references', ['root_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_cmf_mail_references_root_id'), table_name='cmf_mail_references')
    op.drop_index(op.f('ix_cmf_mail_references_right_id'), table_name='cmf_mail_references')
    op.drop_index(op.f('ix_cmf_mail_references_parent_id'), table_name='cmf_mail_references')
    op.drop_index(op.f('ix_cmf_mail_references_left_id'), table_name='cmf_mail_references')
    op.drop_table('cmf_mail_references')
    op.drop_index(op.f('ix_cmf_mail_handler_spectators_root_id'), table_name='cmf_mail_handler_spectators')
    op.drop_index(op.f('ix_cmf_mail_handler_spectators_right_id'), table_name='cmf_mail_handler_spectators')
    op.drop_index(op.f('ix_cmf_mail_handler_spectators_parent_id'), table_name='cmf_mail_handler_spectators')
    op.drop_index(op.f('ix_cmf_mail_handler_spectators_left_id'), table_name='cmf_mail_handler_spectators')
    op.drop_table('cmf_mail_handler_spectators')
    op.drop_index(op.f('ix_cmf_mail_handler_local_links_root_id'), table_name='cmf_mail_handler_local_links')
    op.drop_index(op.f('ix_cmf_mail_handler_local_links_right_id'), table_name='cmf_mail_handler_local_links')
    op.drop_index(op.f('ix_cmf_mail_handler_local_links_parent_id'), table_name='cmf_mail_handler_local_links')
    op.drop_index(op.f('ix_cmf_mail_handler_local_links_left_id'), table_name='cmf_mail_handler_local_links')
    op.drop_table('cmf_mail_handler_local_links')
    op.drop_index(op.f('ix_cmf_mail_handler_executors_root_id'), table_name='cmf_mail_handler_executors')
    op.drop_index(op.f('ix_cmf_mail_handler_executors_right_id'), table_name='cmf_mail_handler_executors')
    op.drop_index(op.f('ix_cmf_mail_handler_executors_parent_id'), table_name='cmf_mail_handler_executors')
    op.drop_index(op.f('ix_cmf_mail_handler_executors_left_id'), table_name='cmf_mail_handler_executors')
    op.drop_table('cmf_mail_handler_executors')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_root_id'), table_name='cmf_mail_handler_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_right_id'), table_name='cmf_mail_handler_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_parent_id'), table_name='cmf_mail_handler_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_owner_assistants_left_id'), table_name='cmf_mail_handler_cmf_owner_assistants')
    op.drop_table('cmf_mail_handler_cmf_owner_assistants')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_root_id'), table_name='cmf_mail_handler_cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_right_id'), table_name='cmf_mail_handler_cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_parent_id'), table_name='cmf_mail_handler_cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_mailbox_folder_left_id'), table_name='cmf_mail_handler_cmf_mailbox_folder')
    op.drop_table('cmf_mail_handler_cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mail_handler_workflow_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_waiting_for_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_tree_parent_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_status_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_scheme_wf_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_root_parent_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_responsible_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_perm_parent_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_perm_acl_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_parent_logic_prefix'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_parent_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_orderno'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_obj_logic_type_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_obj_author_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_name'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_mailbox_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_logic_type_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_logic_prefix'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_is_template'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_default_task_workflow_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_company_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_code'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_viewed_at'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_version'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_owner_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_owner_assistant_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_modified_by_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_modified_at'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_locked_by_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_locked_at'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_import_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_deleted'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_created_at'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cmf_author_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cloned_from_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cache_status_type'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_cache_status_opt_id'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_approved'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_alarm_date'), table_name='cmf_mail_handler')
    op.drop_index(op.f('ix_cmf_mail_handler_activity_id'), table_name='cmf_mail_handler')
    op.drop_table('cmf_mail_handler')
    op.drop_constraint(None, 'cmf_mail', type_='foreignkey')
    op.drop_constraint(None, 'cmf_mail', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_mail_message_id'), table_name='cmf_mail')
    op.drop_index(op.f('ix_cmf_mail_mailbox_folder_id'), table_name='cmf_mail')
    op.drop_index(op.f('ix_cmf_mail_in_reply_to_id'), table_name='cmf_mail')
    op.drop_index(op.f('ix_cmf_mail_handle_obj_id'), table_name='cmf_mail')
    op.drop_column('cmf_mail', 'handle_obj_id')
    op.drop_column('cmf_mail', 'in_reply_to_id')
    op.drop_column('cmf_mail', 'mailbox_folder_id')
    op.drop_column('cmf_mail', 'references_raw')
    op.drop_column('cmf_mail', 'in_reply_to_raw')
    op.drop_column('cmf_mail', 'message_id')
    op.drop_column('cmf_mail', 'imap_uid')
    op.drop_column('cmf_mail', 'mail_headers')
    op.drop_column('cmf_mail', 'text_search')
    op.drop_column('cmf_mail', 'text_html')
    op.drop_column('cmf_mail', 'is_readed')
    op.drop_column('cmf_mail', 'mail_to_json')
    op.drop_column('cmf_mail', 'mail_to')
    op.drop_column('cmf_mail', 'mail_from_name')
    op.drop_column('cmf_mail', 'mail_from')
    op.drop_index(op.f('ix_cmf_mailbox_folder_tree_parent_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_root_parent_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_perm_parent_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_perm_acl_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_parent_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_orderno'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_name_raw'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_name'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_code'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_viewed_at'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_version'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_owner_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_modified_by_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_modified_at'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_locked_by_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_locked_at'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_import_id'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_deleted'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_created_at'), table_name='cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox_folder_cmf_author_id'), table_name='cmf_mailbox_folder')
    op.drop_table('cmf_mailbox_folder')
    op.drop_index(op.f('ix_cmf_mailbox2_executors_root_id'), table_name='cmf_mailbox2_executors')
    op.drop_index(op.f('ix_cmf_mailbox2_executors_right_id'), table_name='cmf_mailbox2_executors')
    op.drop_index(op.f('ix_cmf_mailbox2_executors_parent_id'), table_name='cmf_mailbox2_executors')
    op.drop_index(op.f('ix_cmf_mailbox2_executors_left_id'), table_name='cmf_mailbox2_executors')
    op.drop_table('cmf_mailbox2_executors')
    op.drop_index(op.f('ix_cmf_mailbox2_tree_parent_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_root_parent_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_perm_parent_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_perm_acl_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_parent_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_orderno'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_name'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_code'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_viewed_at'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_version'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_owner_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_modified_by_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_modified_at'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_locked_by_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_locked_at'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_import_id'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_deleted'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_created_at'), table_name='cmf_mailbox2')
    op.drop_index(op.f('ix_cmf_mailbox2_cmf_author_id'), table_name='cmf_mailbox2')
    op.drop_table('cmf_mailbox2')
    # ### end Alembic commands ###
