"""automation trigger

Revision ID: d0fb3f178c44
Revises: 1be38bc7c6d3
Create Date: 2022-11-27 21:01:44.108391

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd0fb3f178c44'
down_revision = '1be38bc7c6d3'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_automation_cron_trigger',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('import_original', sa.Boolean(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('is_favorite', sa.Boolean(), nullable=True),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=True),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=True),
    sa.Column('tree_hidden', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=True),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=True),
    sa.Column('perm_inherit', sa.Boolean(), nullable=True),
    sa.Column('perm_parent_owner_id', sa.String(length=64), nullable=True),
    sa.Column('perm_inherit_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_effective_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=True),
    sa.Column('cron_rule', sa.String(length=64), nullable=True),
    sa.Column('eval_code', 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('cmf_owner_assistant_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('perm_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_parent_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_author_id'), 'cmf_automation_cron_trigger', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_created_at'), 'cmf_automation_cron_trigger', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_deleted'), 'cmf_automation_cron_trigger', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_import_id'), 'cmf_automation_cron_trigger', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_locked_at'), 'cmf_automation_cron_trigger', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_locked_by_id'), 'cmf_automation_cron_trigger', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_modified_at'), 'cmf_automation_cron_trigger', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_modified_by_id'), 'cmf_automation_cron_trigger', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_owner_assistant_id'), 'cmf_automation_cron_trigger', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_owner_id'), 'cmf_automation_cron_trigger', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_version'), 'cmf_automation_cron_trigger', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_cmf_viewed_at'), 'cmf_automation_cron_trigger', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_code'), 'cmf_automation_cron_trigger', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_name'), 'cmf_automation_cron_trigger', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_orderno'), 'cmf_automation_cron_trigger', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_parent_id'), 'cmf_automation_cron_trigger', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_perm_acl_id'), 'cmf_automation_cron_trigger', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_perm_parent_id'), 'cmf_automation_cron_trigger', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_cron_trigger_tree_parent_id'), 'cmf_automation_cron_trigger', ['tree_parent_id'], unique=False)
    op.create_table('cmf_automation_crud_trigger',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('import_original', sa.Boolean(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('is_favorite', sa.Boolean(), nullable=True),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=True),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=True),
    sa.Column('tree_hidden', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=True),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=True),
    sa.Column('perm_inherit', sa.Boolean(), nullable=True),
    sa.Column('perm_parent_owner_id', sa.String(length=64), nullable=True),
    sa.Column('perm_inherit_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_effective_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=True),
    sa.Column('cmf_model_name', sa.String(length=32), nullable=True),
    sa.Column('crud_action', sa.String(length=32), nullable=False),
    sa.Column('eval_code', sa.TEXT(), nullable=True),
    sa.Column('eval_type', 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('cmf_owner_assistant_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('perm_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_parent_id', sa.String(length=64), nullable=True),
    sa.Column('activity_id', sa.String(length=64), nullable=True),
    sa.Column('scheme_wf_id', sa.String(length=64), nullable=True),
    sa.Column('call_trigger_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['activity_id'], ['cmf_activity.id'], ),
    sa.ForeignKeyConstraint(['call_trigger_id'], ['cmf_automation_crud_trigger.id'], ),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['scheme_wf_id'], ['cmf_scheme_wf.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_automation_crud_trigger_activity_id'), 'cmf_automation_crud_trigger', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_call_trigger_id'), 'cmf_automation_crud_trigger', ['call_trigger_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_author_id'), 'cmf_automation_crud_trigger', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_created_at'), 'cmf_automation_crud_trigger', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_deleted'), 'cmf_automation_crud_trigger', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_import_id'), 'cmf_automation_crud_trigger', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_locked_at'), 'cmf_automation_crud_trigger', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_locked_by_id'), 'cmf_automation_crud_trigger', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_modified_at'), 'cmf_automation_crud_trigger', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_modified_by_id'), 'cmf_automation_crud_trigger', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_owner_assistant_id'), 'cmf_automation_crud_trigger', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_owner_id'), 'cmf_automation_crud_trigger', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_version'), 'cmf_automation_crud_trigger', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_viewed_at'), 'cmf_automation_crud_trigger', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_code'), 'cmf_automation_crud_trigger', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_name'), 'cmf_automation_crud_trigger', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_orderno'), 'cmf_automation_crud_trigger', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_parent_id'), 'cmf_automation_crud_trigger', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_perm_acl_id'), 'cmf_automation_crud_trigger', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_perm_parent_id'), 'cmf_automation_crud_trigger', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_scheme_wf_id'), 'cmf_automation_crud_trigger', ['scheme_wf_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_tree_parent_id'), 'cmf_automation_crud_trigger', ['tree_parent_id'], unique=False)
    op.create_table('cmf_automation_crud_trigger_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_automation_crud_trigger.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_logic_type.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_left_id'), 'cmf_automation_crud_trigger_cmf_logic_type', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_parent_id'), 'cmf_automation_crud_trigger_cmf_logic_type', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_right_id'), 'cmf_automation_crud_trigger_cmf_logic_type', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_root_id'), 'cmf_automation_crud_trigger_cmf_logic_type', ['root_id'], unique=False)
    op.create_table('cmf_automation_crud_trigger_cmf_project',
    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_automation_crud_trigger.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_left_id'), 'cmf_automation_crud_trigger_cmf_project', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_parent_id'), 'cmf_automation_crud_trigger_cmf_project', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_right_id'), 'cmf_automation_crud_trigger_cmf_project', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_root_id'), 'cmf_automation_crud_trigger_cmf_project', ['root_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_root_id'), table_name='cmf_automation_crud_trigger_cmf_project')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_right_id'), table_name='cmf_automation_crud_trigger_cmf_project')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_parent_id'), table_name='cmf_automation_crud_trigger_cmf_project')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_project_left_id'), table_name='cmf_automation_crud_trigger_cmf_project')
    op.drop_table('cmf_automation_crud_trigger_cmf_project')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_root_id'), table_name='cmf_automation_crud_trigger_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_right_id'), table_name='cmf_automation_crud_trigger_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_parent_id'), table_name='cmf_automation_crud_trigger_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_logic_type_left_id'), table_name='cmf_automation_crud_trigger_cmf_logic_type')
    op.drop_table('cmf_automation_crud_trigger_cmf_logic_type')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_tree_parent_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_scheme_wf_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_perm_parent_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_perm_acl_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_parent_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_orderno'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_name'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_code'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_viewed_at'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_version'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_owner_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_owner_assistant_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_modified_by_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_modified_at'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_locked_by_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_locked_at'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_import_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_deleted'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_created_at'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_cmf_author_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_call_trigger_id'), table_name='cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_crud_trigger_activity_id'), table_name='cmf_automation_crud_trigger')
    op.drop_table('cmf_automation_crud_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_tree_parent_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_perm_parent_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_perm_acl_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_parent_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_orderno'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_name'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_code'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_viewed_at'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_version'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_owner_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_owner_assistant_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_modified_by_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_modified_at'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_locked_by_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_locked_at'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_import_id'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_deleted'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_created_at'), table_name='cmf_automation_cron_trigger')
    op.drop_index(op.f('ix_cmf_automation_cron_trigger_cmf_author_id'), table_name='cmf_automation_cron_trigger')
    op.drop_table('cmf_automation_cron_trigger')
    # ### end Alembic commands ###
