"""cmf_status_opt

Revision ID: 9abade193458
Revises: 265fdbf1f530
Create Date: 2021-02-24 17:55:32.080078

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9abade193458'
down_revision = 'd112666b2eee'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_status_opt',
    sa.Column('card_name', sa.String(length=256), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_version', sa.Integer(), nullable=True),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('next_alarm', sa.Integer(), nullable=True),
    sa.Column('options', sa.TEXT(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=False),
    sa.Column('status_id', sa.String(length=64), nullable=True),
    sa.Column('status_type', sa.String(length=32), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('work_list_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['status_id'], ['cmf_status.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_status_opt_card_name'), 'cmf_status_opt', ['card_name'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_author_id'), 'cmf_status_opt', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_created_at'), 'cmf_status_opt', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_deleted'), 'cmf_status_opt', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_locked_at'), 'cmf_status_opt', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_locked_by_id'), 'cmf_status_opt', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_modified_at'), 'cmf_status_opt', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_modified_by_id'), 'cmf_status_opt', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_owner_id'), 'cmf_status_opt', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_version'), 'cmf_status_opt', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_cmf_viewed_at'), 'cmf_status_opt', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_code'), 'cmf_status_opt', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_status_opt_name'), 'cmf_status_opt', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_orderno'), 'cmf_status_opt', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_status_id'), 'cmf_status_opt', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_status_opt_work_list_id'), 'cmf_status_opt', ['work_list_id'], unique=False)
    op.add_column('cmf_chat_group', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_chat_group_cache_status_opt_id'), 'cmf_chat_group', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_chat_group', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_chat_topic', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_chat_topic_cache_status_opt_id'), 'cmf_chat_topic', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_chat_topic', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_company', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_company_cache_status_opt_id'), 'cmf_company', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_company', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_deal', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_deal_cache_status_opt_id'), 'cmf_deal', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_deal', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_document', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_document_cache_status_opt_id'), 'cmf_document', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_document', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_invoice', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_invoice_cache_status_opt_id'), 'cmf_invoice', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_invoice', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_lead', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_lead_cache_status_opt_id'), 'cmf_lead', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_lead', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_list', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_list_cache_status_opt_id'), 'cmf_list', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_list', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_mail', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_mail_cache_status_opt_id'), 'cmf_mail', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_mail', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_payment', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_payment_cache_status_opt_id'), 'cmf_payment', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_payment', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_pipeline', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_pipeline_cache_status_opt_id'), 'cmf_pipeline', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_pipeline', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_purchase_order', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_purchase_order_cache_status_opt_id'), 'cmf_purchase_order', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_purchase_order', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_purchase_order_items', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_purchase_order_items_cache_status_opt_id'), 'cmf_purchase_order_items', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_purchase_order_items', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_sales_order', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_sales_order_cache_status_opt_id'), 'cmf_sales_order', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_sales_order', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_stock_move', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_stock_move_cache_status_opt_id'), 'cmf_stock_move', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_stock_move', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_stock_move_items', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_stock_move_items_cache_status_opt_id'), 'cmf_stock_move_items', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_stock_move_items', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_task', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_task_cache_status_opt_id'), 'cmf_task', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_task', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.add_column('cmf_trigger', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_trigger_cache_status_opt_id'), 'cmf_trigger', ['cache_status_opt_id'], unique=False)
    op.drop_index('ix_cmf_trigger_cache_kanban_status_id', table_name='cmf_trigger')
    op.drop_constraint('cmf_trigger_cache_kanban_status_id_fkey', 'cmf_trigger', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_trigger', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    op.drop_column('cmf_trigger', 'cache_kanban_status_id')
    op.add_column('cmf_u_work_post', sa.Column('cache_status_opt_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_u_work_post_cache_status_opt_id'), 'cmf_u_work_post', ['cache_status_opt_id'], unique=False)
    op.create_foreign_key(None, 'cmf_u_work_post', 'cmf_status_opt', ['cache_status_opt_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_u_work_post', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_u_work_post_cache_status_opt_id'), table_name='cmf_u_work_post')
    op.drop_column('cmf_u_work_post', 'cache_status_opt_id')
    op.add_column('cmf_trigger', sa.Column('cache_kanban_status_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_trigger', type_='foreignkey')
    op.create_foreign_key('cmf_trigger_cache_kanban_status_id_fkey', 'cmf_trigger', 'cmf_kanban_status', ['cache_kanban_status_id'], ['id'])
    op.create_index('ix_cmf_trigger_cache_kanban_status_id', 'cmf_trigger', ['cache_kanban_status_id'], unique=False)
    op.drop_index(op.f('ix_cmf_trigger_cache_status_opt_id'), table_name='cmf_trigger')
    op.drop_column('cmf_trigger', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_task', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_task_cache_status_opt_id'), table_name='cmf_task')
    op.drop_column('cmf_task', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_stock_move_items', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_stock_move_items_cache_status_opt_id'), table_name='cmf_stock_move_items')
    op.drop_column('cmf_stock_move_items', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_stock_move', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_stock_move_cache_status_opt_id'), table_name='cmf_stock_move')
    op.drop_column('cmf_stock_move', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_sales_order', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_sales_order_cache_status_opt_id'), table_name='cmf_sales_order')
    op.drop_column('cmf_sales_order', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_purchase_order_items', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cache_status_opt_id'), table_name='cmf_purchase_order_items')
    op.drop_column('cmf_purchase_order_items', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_purchase_order', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_purchase_order_cache_status_opt_id'), table_name='cmf_purchase_order')
    op.drop_column('cmf_purchase_order', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_pipeline', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_pipeline_cache_status_opt_id'), table_name='cmf_pipeline')
    op.drop_column('cmf_pipeline', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_payment', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_payment_cache_status_opt_id'), table_name='cmf_payment')
    op.drop_column('cmf_payment', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_mail', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_mail_cache_status_opt_id'), table_name='cmf_mail')
    op.drop_column('cmf_mail', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_list', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_list_cache_status_opt_id'), table_name='cmf_list')
    op.drop_column('cmf_list', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_lead', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_lead_cache_status_opt_id'), table_name='cmf_lead')
    op.drop_column('cmf_lead', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_invoice', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_invoice_cache_status_opt_id'), table_name='cmf_invoice')
    op.drop_column('cmf_invoice', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_document', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_document_cache_status_opt_id'), table_name='cmf_document')
    op.drop_column('cmf_document', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_deal', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_deal_cache_status_opt_id'), table_name='cmf_deal')
    op.drop_column('cmf_deal', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_company', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_company_cache_status_opt_id'), table_name='cmf_company')
    op.drop_column('cmf_company', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_chat_topic', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_chat_topic_cache_status_opt_id'), table_name='cmf_chat_topic')
    op.drop_column('cmf_chat_topic', 'cache_status_opt_id')
    op.drop_constraint(None, 'cmf_chat_group', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_chat_group_cache_status_opt_id'), table_name='cmf_chat_group')
    op.drop_column('cmf_chat_group', 'cache_status_opt_id')
    op.drop_index(op.f('ix_cmf_status_opt_work_list_id'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_status_id'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_orderno'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_name'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_code'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_viewed_at'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_version'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_owner_id'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_modified_by_id'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_modified_at'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_locked_by_id'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_locked_at'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_deleted'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_created_at'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_cmf_author_id'), table_name='cmf_status_opt')
    op.drop_index(op.f('ix_cmf_status_opt_card_name'), table_name='cmf_status_opt')
    op.drop_table('cmf_status_opt')
    # ### end Alembic commands ###
