"""mail

Revision ID: 528e7d5a5be9
Revises: bc64b34418f1
Create Date: 2023-03-17 16:06:08.772151

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '528e7d5a5be9'
down_revision = 'bc64b34418f1'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_cmf_mail_local_links_left_id', table_name='cmf_mail_local_links')
    op.drop_index('ix_cmf_mail_local_links_parent_id', table_name='cmf_mail_local_links')
    op.drop_index('ix_cmf_mail_local_links_right_id', table_name='cmf_mail_local_links')
    op.drop_index('ix_cmf_mail_local_links_root_id', table_name='cmf_mail_local_links')
    op.drop_table('cmf_mail_local_links')
    op.drop_index('ix_cmf_mail_executors_left_id', table_name='cmf_mail_executors')
    op.drop_index('ix_cmf_mail_executors_parent_id', table_name='cmf_mail_executors')
    op.drop_index('ix_cmf_mail_executors_right_id', table_name='cmf_mail_executors')
    op.drop_index('ix_cmf_mail_executors_root_id', table_name='cmf_mail_executors')
    op.drop_table('cmf_mail_executors')
    op.drop_index('ix_cmf_mail_cmf_owner_assistants_left_id', table_name='cmf_mail_cmf_owner_assistants')
    op.drop_index('ix_cmf_mail_cmf_owner_assistants_parent_id', table_name='cmf_mail_cmf_owner_assistants')
    op.drop_index('ix_cmf_mail_cmf_owner_assistants_right_id', table_name='cmf_mail_cmf_owner_assistants')
    op.drop_index('ix_cmf_mail_cmf_owner_assistants_root_id', table_name='cmf_mail_cmf_owner_assistants')
    op.drop_table('cmf_mail_cmf_owner_assistants')
    op.drop_index('ix_cmf_mail_spectators_left_id', table_name='cmf_mail_spectators')
    op.drop_index('ix_cmf_mail_spectators_parent_id', table_name='cmf_mail_spectators')
    op.drop_index('ix_cmf_mail_spectators_right_id', table_name='cmf_mail_spectators')
    op.drop_index('ix_cmf_mail_spectators_root_id', table_name='cmf_mail_spectators')
    op.drop_table('cmf_mail_spectators')
    op.drop_index('ix_cmf_mail_activity_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_alarm_date', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_approved', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_cache_status_opt_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_cache_status_type', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_cloned_from_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_cmf_owner_assistant_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_company_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_default_task_workflow_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_is_template', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_logic_prefix', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_logic_type_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_parent_logic_prefix', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_responsible_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_scheme_wf_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_status_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_waiting_for_id', table_name='cmf_mail')
    op.drop_index('ix_cmf_mail_workflow_id', table_name='cmf_mail')
    op.drop_constraint('cmf_mail_status_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_logic_type_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_workflow_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_company_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_scheme_wf_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_cache_status_opt_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_default_task_workflow_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_constraint('cmf_mail_activity_id_fkey', 'cmf_mail', type_='foreignkey')
    op.drop_column('cmf_mail', 'status_modified_at')
    op.drop_column('cmf_mail', 'period_interval')
    op.drop_column('cmf_mail', 'perm_policy')
    op.drop_column('cmf_mail', 'mark')
    op.drop_column('cmf_mail', 'scheme_wf_id')
    op.drop_column('cmf_mail', 'plan_end_date')
    op.drop_column('cmf_mail', 'status_review_at')
    op.drop_column('cmf_mail', 'no_control')
    op.drop_column('cmf_mail', 'default_task_workflow_id')
    op.drop_column('cmf_mail', 'plan_start_date')
    op.drop_column('cmf_mail', 'status_in_progress_start')
    op.drop_column('cmf_mail', 'cmf_owner_assistant_id')
    op.drop_column('cmf_mail', 'is_public')
    op.drop_column('cmf_mail', 'sharelink_hash')
    op.drop_column('cmf_mail', 'parent_logic_prefix')
    op.drop_column('cmf_mail', 'status_in_progress_end')
    op.drop_column('cmf_mail', 'approved')
    op.drop_column('cmf_mail', 'responsible_id')
    op.drop_column('cmf_mail', 'waiting_for_id')
    op.drop_column('cmf_mail', 'is_template')
    op.drop_column('cmf_mail', 'cache_status_opt_id')
    op.drop_column('cmf_mail', 'is_public_editable')
    op.drop_column('cmf_mail', 'deadline')
    op.drop_column('cmf_mail', 'is_public_comments')
    op.drop_column('cmf_mail', 'cloned_from_id')
    op.drop_column('cmf_mail', 'period_next_date')
    op.drop_column('cmf_mail', 'perm_policy_guest')
    op.drop_column('cmf_mail', 'alarm_date')
    op.drop_column('cmf_mail', 'is_penalty')
    op.drop_column('cmf_mail', 'status_id')
    op.drop_column('cmf_mail', 'cache_status_type')
    op.drop_column('cmf_mail', 'status_closed_at')
    op.drop_column('cmf_mail', 'company_id')
    op.drop_column('cmf_mail', 'cache_fields')
    op.drop_column('cmf_mail', 'priority')
    op.drop_column('cmf_mail', 'logic_type_id')
    op.drop_column('cmf_mail', 'ui_view_form')
    op.drop_column('cmf_mail', 'activity_id')
    op.drop_column('cmf_mail', 'perm_policy_sharelink')
    op.drop_column('cmf_mail', 'workflow_id')
    op.drop_column('cmf_mail', 'perm_policy_anonymous')
    op.drop_column('cmf_mail', 'logic_prefix')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_mail', sa.Column('logic_prefix', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('perm_policy_anonymous', sa.VARCHAR(length=32), server_default=sa.text("'default'::character varying"), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('workflow_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('perm_policy_sharelink', sa.VARCHAR(length=32), server_default=sa.text("'default'::character varying"), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('activity_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('ui_view_form', sa.VARCHAR(length=32), server_default=sa.text("'mail'::character varying"), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('logic_type_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('priority', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('cache_fields', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('company_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('status_closed_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('cache_status_type', sa.VARCHAR(length=32), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('status_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('is_penalty', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('alarm_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('perm_policy_guest', sa.VARCHAR(length=32), server_default=sa.text("'default'::character varying"), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('period_next_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('cloned_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('is_public_comments', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('deadline', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('is_public_editable', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('cache_status_opt_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('is_template', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('waiting_for_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('responsible_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('approved', sa.BOOLEAN(), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('status_in_progress_end', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('parent_logic_prefix', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('sharelink_hash', sa.VARCHAR(length=32), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('is_public', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('cmf_owner_assistant_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('status_in_progress_start', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('plan_start_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('default_task_workflow_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('no_control', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('status_review_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('plan_end_date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('scheme_wf_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('mark', sa.VARCHAR(length=32), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('perm_policy', sa.VARCHAR(length=32), server_default=sa.text("'default'::character varying"), autoincrement=False, nullable=False))
    op.add_column('cmf_mail', sa.Column('period_interval', sa.VARCHAR(length=32), autoincrement=False, nullable=True))
    op.add_column('cmf_mail', sa.Column('status_modified_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
    op.create_foreign_key('cmf_mail_activity_id_fkey', 'cmf_mail', 'cmf_activity', ['activity_id'], ['id'])
    op.create_foreign_key('cmf_mail_default_task_workflow_id_fkey', 'cmf_mail', 'cmf_workflow', ['default_task_workflow_id'], ['id'])
    op.create_foreign_key('cmf_mail_cache_status_opt_id_fkey', 'cmf_mail', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.create_foreign_key('cmf_mail_scheme_wf_id_fkey', 'cmf_mail', 'cmf_scheme_wf', ['scheme_wf_id'], ['id'])
    op.create_foreign_key('cmf_mail_company_id_fkey', 'cmf_mail', 'cmf_company', ['company_id'], ['id'])
    op.create_foreign_key('cmf_mail_workflow_id_fkey', 'cmf_mail', 'cmf_workflow', ['workflow_id'], ['id'])
    op.create_foreign_key('cmf_mail_logic_type_id_fkey', 'cmf_mail', 'cmf_logic_type', ['logic_type_id'], ['id'])
    op.create_foreign_key('cmf_mail_status_id_fkey', 'cmf_mail', 'cmf_status', ['status_id'], ['id'])
    op.create_index('ix_cmf_mail_workflow_id', 'cmf_mail', ['workflow_id'], unique=False)
    op.create_index('ix_cmf_mail_waiting_for_id', 'cmf_mail', ['waiting_for_id'], unique=False)
    op.create_index('ix_cmf_mail_status_id', 'cmf_mail', ['status_id'], unique=False)
    op.create_index('ix_cmf_mail_scheme_wf_id', 'cmf_mail', ['scheme_wf_id'], unique=False)
    op.create_index('ix_cmf_mail_responsible_id', 'cmf_mail', ['responsible_id'], unique=False)
    op.create_index('ix_cmf_mail_parent_logic_prefix', 'cmf_mail', ['parent_logic_prefix'], unique=False)
    op.create_index('ix_cmf_mail_logic_type_id', 'cmf_mail', ['logic_type_id'], unique=False)
    op.create_index('ix_cmf_mail_logic_prefix', 'cmf_mail', ['logic_prefix'], unique=False)
    op.create_index('ix_cmf_mail_is_template', 'cmf_mail', ['is_template'], unique=False)
    op.create_index('ix_cmf_mail_default_task_workflow_id', 'cmf_mail', ['default_task_workflow_id'], unique=False)
    op.create_index('ix_cmf_mail_company_id', 'cmf_mail', ['company_id'], unique=False)
    op.create_index('ix_cmf_mail_cmf_owner_assistant_id', 'cmf_mail', ['cmf_owner_assistant_id'], unique=False)
    op.create_index('ix_cmf_mail_cloned_from_id', 'cmf_mail', ['cloned_from_id'], unique=False)
    op.create_index('ix_cmf_mail_cache_status_type', 'cmf_mail', ['cache_status_type'], unique=False)
    op.create_index('ix_cmf_mail_cache_status_opt_id', 'cmf_mail', ['cache_status_opt_id'], unique=False)
    op.create_index('ix_cmf_mail_approved', 'cmf_mail', ['approved'], unique=False)
    op.create_index('ix_cmf_mail_alarm_date', 'cmf_mail', ['alarm_date'], unique=False)
    op.create_index('ix_cmf_mail_activity_id', 'cmf_mail', ['activity_id'], unique=False)
    op.create_table('cmf_mail_spectators',
    sa.Column('description', sa.VARCHAR(length=4096), autoincrement=False, nullable=True),
    sa.Column('id', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
    sa.Column('left_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('left_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('root_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='cmf_mail_spectators_pkey')
    )
    op.create_index('ix_cmf_mail_spectators_root_id', 'cmf_mail_spectators', ['root_id'], unique=False)
    op.create_index('ix_cmf_mail_spectators_right_id', 'cmf_mail_spectators', ['right_id'], unique=False)
    op.create_index('ix_cmf_mail_spectators_parent_id', 'cmf_mail_spectators', ['parent_id'], unique=False)
    op.create_index('ix_cmf_mail_spectators_left_id', 'cmf_mail_spectators', ['left_id'], unique=False)
    op.create_table('cmf_mail_cmf_owner_assistants',
    sa.Column('id', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
    sa.Column('parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('root_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('description', sa.VARCHAR(length=4096), autoincrement=False, nullable=True),
    sa.Column('left_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('left_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('right_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='cmf_mail_cmf_owner_assistants_pkey')
    )
    op.create_index('ix_cmf_mail_cmf_owner_assistants_root_id', 'cmf_mail_cmf_owner_assistants', ['root_id'], unique=False)
    op.create_index('ix_cmf_mail_cmf_owner_assistants_right_id', 'cmf_mail_cmf_owner_assistants', ['right_id'], unique=False)
    op.create_index('ix_cmf_mail_cmf_owner_assistants_parent_id', 'cmf_mail_cmf_owner_assistants', ['parent_id'], unique=False)
    op.create_index('ix_cmf_mail_cmf_owner_assistants_left_id', 'cmf_mail_cmf_owner_assistants', ['left_id'], unique=False)
    op.create_table('cmf_mail_executors',
    sa.Column('description', sa.VARCHAR(length=4096), autoincrement=False, nullable=True),
    sa.Column('id', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
    sa.Column('left_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('left_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('root_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='cmf_mail_executors_pkey')
    )
    op.create_index('ix_cmf_mail_executors_root_id', 'cmf_mail_executors', ['root_id'], unique=False)
    op.create_index('ix_cmf_mail_executors_right_id', 'cmf_mail_executors', ['right_id'], unique=False)
    op.create_index('ix_cmf_mail_executors_parent_id', 'cmf_mail_executors', ['parent_id'], unique=False)
    op.create_index('ix_cmf_mail_executors_left_id', 'cmf_mail_executors', ['left_id'], unique=False)
    op.create_table('cmf_mail_local_links',
    sa.Column('id', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
    sa.Column('parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('root_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('description', sa.VARCHAR(length=4096), autoincrement=False, nullable=True),
    sa.Column('left_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('left_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('right_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='cmf_mail_local_links_pkey')
    )
    op.create_index('ix_cmf_mail_local_links_root_id', 'cmf_mail_local_links', ['root_id'], unique=False)
    op.create_index('ix_cmf_mail_local_links_right_id', 'cmf_mail_local_links', ['right_id'], unique=False)
    op.create_index('ix_cmf_mail_local_links_parent_id', 'cmf_mail_local_links', ['parent_id'], unique=False)
    op.create_index('ix_cmf_mail_local_links_left_id', 'cmf_mail_local_links', ['left_id'], unique=False)
    # ### end Alembic commands ###
