"""is_template

Revision ID: b2d53344e430
Revises: 784b1bda623c
Create Date: 2022-02-21 16:47:37.981275

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b2d53344e430'
down_revision = '784b1bda623c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_chat_group', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_chat_group', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_chat_group_period_clone_from_id', table_name='cmf_chat_group')
    op.create_index(op.f('ix_cmf_chat_group_cloned_from_id'), 'cmf_chat_group', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_chat_group_is_template'), 'cmf_chat_group', ['is_template'], unique=False)
    op.drop_column('cmf_chat_group', 'period_clone_from_id')
    op.add_column('cmf_chat_topic', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_chat_topic', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_chat_topic_period_clone_from_id', table_name='cmf_chat_topic')
    op.create_index(op.f('ix_cmf_chat_topic_cloned_from_id'), 'cmf_chat_topic', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_chat_topic_is_template'), 'cmf_chat_topic', ['is_template'], unique=False)
    op.drop_column('cmf_chat_topic', 'period_clone_from_id')
    op.add_column('cmf_company', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_company', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_company_period_clone_from_id', table_name='cmf_company')
    op.create_index(op.f('ix_cmf_company_cloned_from_id'), 'cmf_company', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_company_is_template'), 'cmf_company', ['is_template'], unique=False)
    op.drop_column('cmf_company', 'period_clone_from_id')
    op.add_column('cmf_deal', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_deal', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_deal_period_clone_from_id', table_name='cmf_deal')
    op.create_index(op.f('ix_cmf_deal_cloned_from_id'), 'cmf_deal', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_deal_is_template'), 'cmf_deal', ['is_template'], unique=False)
    op.drop_column('cmf_deal', 'period_clone_from_id')
    op.add_column('cmf_document', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_document', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_document_period_clone_from_id', table_name='cmf_document')
    op.create_index(op.f('ix_cmf_document_cloned_from_id'), 'cmf_document', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_document_is_template'), 'cmf_document', ['is_template'], unique=False)
    op.drop_column('cmf_document', 'period_clone_from_id')
    op.add_column('cmf_invoice', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_invoice', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_invoice_period_clone_from_id', table_name='cmf_invoice')
    op.create_index(op.f('ix_cmf_invoice_cloned_from_id'), 'cmf_invoice', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_invoice_is_template'), 'cmf_invoice', ['is_template'], unique=False)
    op.drop_column('cmf_invoice', 'period_clone_from_id')
    op.add_column('cmf_lead', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_lead', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_lead_period_clone_from_id', table_name='cmf_lead')
    op.create_index(op.f('ix_cmf_lead_cloned_from_id'), 'cmf_lead', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_lead_is_template'), 'cmf_lead', ['is_template'], unique=False)
    op.drop_column('cmf_lead', 'period_clone_from_id')
    op.add_column('cmf_list', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_list', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_list_period_clone_from_id', table_name='cmf_list')
    op.create_index(op.f('ix_cmf_list_cloned_from_id'), 'cmf_list', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_list_is_template'), 'cmf_list', ['is_template'], unique=False)
    op.drop_column('cmf_list', 'period_clone_from_id')
    op.add_column('cmf_mail', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_mail', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_mail_period_clone_from_id', table_name='cmf_mail')
    op.create_index(op.f('ix_cmf_mail_cloned_from_id'), 'cmf_mail', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_mail_is_template'), 'cmf_mail', ['is_template'], unique=False)
    op.drop_column('cmf_mail', 'period_clone_from_id')
    op.add_column('cmf_payment', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_payment', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_payment_period_clone_from_id', table_name='cmf_payment')
    op.create_index(op.f('ix_cmf_payment_cloned_from_id'), 'cmf_payment', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_payment_is_template'), 'cmf_payment', ['is_template'], unique=False)
    op.drop_column('cmf_payment', 'period_clone_from_id')
    op.add_column('cmf_pipeline', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_pipeline', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_pipeline_period_clone_from_id', table_name='cmf_pipeline')
    op.create_index(op.f('ix_cmf_pipeline_cloned_from_id'), 'cmf_pipeline', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_pipeline_is_template'), 'cmf_pipeline', ['is_template'], unique=False)
    op.drop_column('cmf_pipeline', 'period_clone_from_id')
    op.add_column('cmf_project', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_project', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_project_period_clone_from_id', table_name='cmf_project')
    op.create_index(op.f('ix_cmf_project_cloned_from_id'), 'cmf_project', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_project_is_template'), 'cmf_project', ['is_template'], unique=False)
    op.drop_column('cmf_project', 'period_clone_from_id')
    op.add_column('cmf_purchase_order', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_purchase_order', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_purchase_order_period_clone_from_id', table_name='cmf_purchase_order')
    op.create_index(op.f('ix_cmf_purchase_order_cloned_from_id'), 'cmf_purchase_order', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_is_template'), 'cmf_purchase_order', ['is_template'], unique=False)
    op.drop_column('cmf_purchase_order', 'period_clone_from_id')
    op.add_column('cmf_purchase_order_items', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_purchase_order_items', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_purchase_order_items_period_clone_from_id', table_name='cmf_purchase_order_items')
    op.create_index(op.f('ix_cmf_purchase_order_items_cloned_from_id'), 'cmf_purchase_order_items', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_is_template'), 'cmf_purchase_order_items', ['is_template'], unique=False)
    op.drop_column('cmf_purchase_order_items', 'period_clone_from_id')
    op.add_column('cmf_stock_move', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_stock_move', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_stock_move_period_clone_from_id', table_name='cmf_stock_move')
    op.create_index(op.f('ix_cmf_stock_move_cloned_from_id'), 'cmf_stock_move', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_is_template'), 'cmf_stock_move', ['is_template'], unique=False)
    op.drop_column('cmf_stock_move', 'period_clone_from_id')
    op.add_column('cmf_stock_move_items', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_stock_move_items', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_stock_move_items_period_clone_from_id', table_name='cmf_stock_move_items')
    op.create_index(op.f('ix_cmf_stock_move_items_cloned_from_id'), 'cmf_stock_move_items', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_is_template'), 'cmf_stock_move_items', ['is_template'], unique=False)
    op.drop_column('cmf_stock_move_items', 'period_clone_from_id')
    op.add_column('cmf_task', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_task', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_task_period_clone_from_id', table_name='cmf_task')
    op.create_index(op.f('ix_cmf_task_cloned_from_id'), 'cmf_task', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_task_is_template'), 'cmf_task', ['is_template'], unique=False)
    op.drop_column('cmf_task', 'period_clone_from_id')
    op.add_column('cmf_u_work_post', sa.Column('cloned_from_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_u_work_post', sa.Column('is_template', sa.Boolean(), nullable=True))
    op.drop_index('ix_cmf_u_work_post_period_clone_from_id', table_name='cmf_u_work_post')
    op.create_index(op.f('ix_cmf_u_work_post_cloned_from_id'), 'cmf_u_work_post', ['cloned_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_u_work_post_is_template'), 'cmf_u_work_post', ['is_template'], unique=False)
    op.drop_column('cmf_u_work_post', 'period_clone_from_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_u_work_post', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_u_work_post_is_template'), table_name='cmf_u_work_post')
    op.drop_index(op.f('ix_cmf_u_work_post_cloned_from_id'), table_name='cmf_u_work_post')
    op.create_index('ix_cmf_u_work_post_period_clone_from_id', 'cmf_u_work_post', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_u_work_post', 'is_template')
    op.drop_column('cmf_u_work_post', 'cloned_from_id')
    op.add_column('cmf_task', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_task_is_template'), table_name='cmf_task')
    op.drop_index(op.f('ix_cmf_task_cloned_from_id'), table_name='cmf_task')
    op.create_index('ix_cmf_task_period_clone_from_id', 'cmf_task', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_task', 'is_template')
    op.drop_column('cmf_task', 'cloned_from_id')
    op.add_column('cmf_stock_move_items', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_stock_move_items_is_template'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cloned_from_id'), table_name='cmf_stock_move_items')
    op.create_index('ix_cmf_stock_move_items_period_clone_from_id', 'cmf_stock_move_items', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_stock_move_items', 'is_template')
    op.drop_column('cmf_stock_move_items', 'cloned_from_id')
    op.add_column('cmf_stock_move', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_stock_move_is_template'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cloned_from_id'), table_name='cmf_stock_move')
    op.create_index('ix_cmf_stock_move_period_clone_from_id', 'cmf_stock_move', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_stock_move', 'is_template')
    op.drop_column('cmf_stock_move', 'cloned_from_id')
    op.add_column('cmf_purchase_order_items', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_purchase_order_items_is_template'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cloned_from_id'), table_name='cmf_purchase_order_items')
    op.create_index('ix_cmf_purchase_order_items_period_clone_from_id', 'cmf_purchase_order_items', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_purchase_order_items', 'is_template')
    op.drop_column('cmf_purchase_order_items', 'cloned_from_id')
    op.add_column('cmf_purchase_order', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_purchase_order_is_template'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cloned_from_id'), table_name='cmf_purchase_order')
    op.create_index('ix_cmf_purchase_order_period_clone_from_id', 'cmf_purchase_order', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_purchase_order', 'is_template')
    op.drop_column('cmf_purchase_order', 'cloned_from_id')
    op.add_column('cmf_project', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_project_is_template'), table_name='cmf_project')
    op.drop_index(op.f('ix_cmf_project_cloned_from_id'), table_name='cmf_project')
    op.create_index('ix_cmf_project_period_clone_from_id', 'cmf_project', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_project', 'is_template')
    op.drop_column('cmf_project', 'cloned_from_id')
    op.add_column('cmf_pipeline', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_pipeline_is_template'), table_name='cmf_pipeline')
    op.drop_index(op.f('ix_cmf_pipeline_cloned_from_id'), table_name='cmf_pipeline')
    op.create_index('ix_cmf_pipeline_period_clone_from_id', 'cmf_pipeline', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_pipeline', 'is_template')
    op.drop_column('cmf_pipeline', 'cloned_from_id')
    op.add_column('cmf_payment', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_payment_is_template'), table_name='cmf_payment')
    op.drop_index(op.f('ix_cmf_payment_cloned_from_id'), table_name='cmf_payment')
    op.create_index('ix_cmf_payment_period_clone_from_id', 'cmf_payment', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_payment', 'is_template')
    op.drop_column('cmf_payment', 'cloned_from_id')
    op.add_column('cmf_mail', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_mail_is_template'), table_name='cmf_mail')
    op.drop_index(op.f('ix_cmf_mail_cloned_from_id'), table_name='cmf_mail')
    op.create_index('ix_cmf_mail_period_clone_from_id', 'cmf_mail', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_mail', 'is_template')
    op.drop_column('cmf_mail', 'cloned_from_id')
    op.add_column('cmf_list', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_list_is_template'), table_name='cmf_list')
    op.drop_index(op.f('ix_cmf_list_cloned_from_id'), table_name='cmf_list')
    op.create_index('ix_cmf_list_period_clone_from_id', 'cmf_list', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_list', 'is_template')
    op.drop_column('cmf_list', 'cloned_from_id')
    op.add_column('cmf_lead', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_lead_is_template'), table_name='cmf_lead')
    op.drop_index(op.f('ix_cmf_lead_cloned_from_id'), table_name='cmf_lead')
    op.create_index('ix_cmf_lead_period_clone_from_id', 'cmf_lead', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_lead', 'is_template')
    op.drop_column('cmf_lead', 'cloned_from_id')
    op.add_column('cmf_invoice', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_invoice_is_template'), table_name='cmf_invoice')
    op.drop_index(op.f('ix_cmf_invoice_cloned_from_id'), table_name='cmf_invoice')
    op.create_index('ix_cmf_invoice_period_clone_from_id', 'cmf_invoice', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_invoice', 'is_template')
    op.drop_column('cmf_invoice', 'cloned_from_id')
    op.add_column('cmf_document', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_document_is_template'), table_name='cmf_document')
    op.drop_index(op.f('ix_cmf_document_cloned_from_id'), table_name='cmf_document')
    op.create_index('ix_cmf_document_period_clone_from_id', 'cmf_document', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_document', 'is_template')
    op.drop_column('cmf_document', 'cloned_from_id')
    op.add_column('cmf_deal', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_deal_is_template'), table_name='cmf_deal')
    op.drop_index(op.f('ix_cmf_deal_cloned_from_id'), table_name='cmf_deal')
    op.create_index('ix_cmf_deal_period_clone_from_id', 'cmf_deal', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_deal', 'is_template')
    op.drop_column('cmf_deal', 'cloned_from_id')
    op.add_column('cmf_company', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_company_is_template'), table_name='cmf_company')
    op.drop_index(op.f('ix_cmf_company_cloned_from_id'), table_name='cmf_company')
    op.create_index('ix_cmf_company_period_clone_from_id', 'cmf_company', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_company', 'is_template')
    op.drop_column('cmf_company', 'cloned_from_id')
    op.add_column('cmf_chat_topic', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_chat_topic_is_template'), table_name='cmf_chat_topic')
    op.drop_index(op.f('ix_cmf_chat_topic_cloned_from_id'), table_name='cmf_chat_topic')
    op.create_index('ix_cmf_chat_topic_period_clone_from_id', 'cmf_chat_topic', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_chat_topic', 'is_template')
    op.drop_column('cmf_chat_topic', 'cloned_from_id')
    op.add_column('cmf_chat_group', sa.Column('period_clone_from_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_cmf_chat_group_is_template'), table_name='cmf_chat_group')
    op.drop_index(op.f('ix_cmf_chat_group_cloned_from_id'), table_name='cmf_chat_group')
    op.create_index('ix_cmf_chat_group_period_clone_from_id', 'cmf_chat_group', ['period_clone_from_id'], unique=False)
    op.drop_column('cmf_chat_group', 'is_template')
    op.drop_column('cmf_chat_group', 'cloned_from_id')
    # ### end Alembic commands ###
