"""populate system column

Revision ID: 1b2409e7f83a
Revises: adbc798a2e1c
Create Date: 2021-06-23 14:11:00.342717

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1b2409e7f83a'
down_revision = 'adbc798a2e1c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_active_entity_filter', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_active_entity_filter set system = false')
    op.alter_column('cmf_active_entity_filter', 'system', nullable=False)
    op.add_column('cmf_activity', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_activity set system = false')
    op.alter_column('cmf_activity', 'system', nullable=False)
    op.add_column('cmf_attachment', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_attachment set system = false')
    op.alter_column('cmf_attachment', 'system', nullable=False)
    op.add_column('cmf_balance', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_balance set system = false')
    op.alter_column('cmf_balance', 'system', nullable=False)
    op.add_column('cmf_balance_operation', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_balance_operation set system = false')
    op.alter_column('cmf_balance_operation', 'system', nullable=False)
    op.add_column('cmf_card', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_card set system = false')
    op.alter_column('cmf_card', 'system', nullable=False)
    op.add_column('cmf_channel_message', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_channel_message set system = false')
    op.alter_column('cmf_channel_message', 'system', nullable=False)
    op.add_column('cmf_chat_group', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_chat_group set system = false')
    op.alter_column('cmf_chat_group', 'system', nullable=False)
    op.add_column('cmf_chat_topic', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_chat_topic set system = false')
    op.alter_column('cmf_chat_topic', 'system', nullable=False)
    op.add_column('cmf_comment', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_comment set system = false')
    op.alter_column('cmf_comment', 'system', nullable=False)
    op.add_column('cmf_company', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_company set system = false')
    op.alter_column('cmf_company', 'system', nullable=False)
    op.add_column('cmf_currency', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_currency set system = false')
    op.alter_column('cmf_currency', 'system', nullable=False)
    op.add_column('cmf_deal', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_deal set system = false')
    op.alter_column('cmf_deal', 'system', nullable=False)
    op.add_column('cmf_document', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_document set system = false')
    op.alter_column('cmf_document', 'system', nullable=False)
    op.add_column('cmf_feed', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_feed set system = false')
    op.alter_column('cmf_feed', 'system', nullable=False)
    op.add_column('cmf_folder', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_folder set system = false')
    op.alter_column('cmf_folder', 'system', nullable=False)
    op.add_column('cmf_form', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_form set system = false')
    op.alter_column('cmf_form', 'system', nullable=False)
    op.add_column('cmf_form_field', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_form_field set system = false')
    op.alter_column('cmf_form_field', 'system', nullable=False)
    op.add_column('cmf_import', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_import set system = false')
    op.alter_column('cmf_import', 'system', nullable=False)
    op.add_column('cmf_integration', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_integration set system = false')
    op.alter_column('cmf_integration', 'system', nullable=False)
    op.add_column('cmf_invoice', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_invoice set system = false')
    op.alter_column('cmf_invoice', 'system', nullable=False)
    op.add_column('cmf_invoice_items', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_invoice_items set system = false')
    op.alter_column('cmf_invoice_items', 'system', nullable=False)
    op.add_column('cmf_job', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_job set system = false')
    op.alter_column('cmf_job', 'system', nullable=False)
    op.add_column('cmf_lead', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_lead set system = false')
    op.alter_column('cmf_lead', 'system', nullable=False)
    op.add_column('cmf_list', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_list set system = false')
    op.alter_column('cmf_list', 'system', nullable=False)
    op.add_column('cmf_mail', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_mail set system = false')
    op.alter_column('cmf_mail', 'system', nullable=False)
    op.add_column('cmf_mail_signature', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_mail_signature set system = false')
    op.alter_column('cmf_mail_signature', 'system', nullable=False)
    op.add_column('cmf_mail_template', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_mail_template set system = false')
    op.alter_column('cmf_mail_template', 'system', nullable=False)
    op.add_column('cmf_mailbox', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_mailbox set system = false')
    op.alter_column('cmf_mailbox', 'system', nullable=False)
    op.add_column('cmf_notify', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_notify set system = false')
    op.alter_column('cmf_notify', 'system', nullable=False)
    op.add_column('cmf_org_unit', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_org_unit set system = false')
    op.alter_column('cmf_org_unit', 'system', nullable=False)
    op.add_column('cmf_payment', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_payment set system = false')
    op.alter_column('cmf_payment', 'system', nullable=False)
    op.add_column('cmf_person', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_person set system = false')
    op.alter_column('cmf_person', 'system', nullable=False)
    op.add_column('cmf_person_group', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_person_group set system = false')
    op.alter_column('cmf_person_group', 'system', nullable=False)
    op.add_column('cmf_pipeline', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_pipeline set system = false')
    op.alter_column('cmf_pipeline', 'system', nullable=False)
    op.add_column('cmf_plan', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_plan set system = false')
    op.alter_column('cmf_plan', 'system', nullable=False)
    op.add_column('cmf_price', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_price set system = false')
    op.alter_column('cmf_price', 'system', nullable=False)
    op.add_column('cmf_print_tmpl', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_print_tmpl set system = false')
    op.alter_column('cmf_print_tmpl', 'system', nullable=False)
    op.add_column('cmf_product', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_product set system = false')
    op.alter_column('cmf_product', 'system', nullable=False)
    op.add_column('cmf_project', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_project set system = false')
    op.alter_column('cmf_project', 'system', nullable=False)
    op.add_column('cmf_purchase_order', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_purchase_order set system = false')
    op.alter_column('cmf_purchase_order', 'system', nullable=False)
    op.add_column('cmf_purchase_order_items', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_purchase_order_items set system = false')
    op.alter_column('cmf_purchase_order_items', 'system', nullable=False)
    op.add_column('cmf_role', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_role set system = false')
    op.alter_column('cmf_role', 'system', nullable=False)
    op.add_column('cmf_sales_order', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_sales_order set system = false')
    op.alter_column('cmf_sales_order', 'system', nullable=False)
    op.add_column('cmf_sales_order_items', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_sales_order_items set system = false')
    op.alter_column('cmf_sales_order_items', 'system', nullable=False)
    op.add_column('cmf_staff_control', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_staff_control set system = false')
    op.alter_column('cmf_staff_control', 'system', nullable=False)
    op.add_column('cmf_staff_control_settings', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_staff_control_settings set system = false')
    op.alter_column('cmf_staff_control_settings', 'system', nullable=False)
    op.add_column('cmf_status_opt', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_status_opt set system = false')
    op.alter_column('cmf_status_opt', 'system', nullable=False)
    op.add_column('cmf_stock', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_stock set system = false')
    op.alter_column('cmf_stock', 'system', nullable=False)
    op.add_column('cmf_stock_items', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_stock_items set system = false')
    op.alter_column('cmf_stock_items', 'system', nullable=False)
    op.add_column('cmf_stock_move', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_stock_move set system = false')
    op.alter_column('cmf_stock_move', 'system', nullable=False)
    op.add_column('cmf_stock_move_items', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_stock_move_items set system = false')
    op.alter_column('cmf_stock_move_items', 'system', nullable=False)
    op.add_column('cmf_stock_operations', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_stock_operations set system = false')
    op.alter_column('cmf_stock_operations', 'system', nullable=False)
    op.add_column('cmf_subscription', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_subscription set system = false')
    op.alter_column('cmf_subscription', 'system', nullable=False)
    op.add_column('cmf_tag', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_tag set system = false')
    op.alter_column('cmf_tag', 'system', nullable=False)
    op.add_column('cmf_task', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_task set system = false')
    op.alter_column('cmf_task', 'system', nullable=False)
    op.add_column('cmf_trigger', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_trigger set system = false')
    op.alter_column('cmf_trigger', 'system', nullable=False)
    op.add_column('cmf_u_work_post', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_u_work_post set system = false')
    op.alter_column('cmf_u_work_post', 'system', nullable=False)
    op.add_column('cmf_unit', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_unit set system = false')
    op.alter_column('cmf_unit', 'system', nullable=False)
    op.add_column('cmf_whatsapp', sa.Column('system', sa.Boolean(), nullable=True))
    op.execute('update cmf_whatsapp set system = false')
    op.alter_column('cmf_whatsapp', 'system', nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('cmf_whatsapp', 'system')
    op.drop_column('cmf_unit', 'system')
    op.drop_column('cmf_u_work_post', 'system')
    op.drop_column('cmf_trigger', 'system')
    op.drop_column('cmf_task', 'system')
    op.drop_column('cmf_tag', 'system')
    op.drop_column('cmf_subscription', 'system')
    op.drop_column('cmf_stock_operations', 'system')
    op.drop_column('cmf_stock_move_items', 'system')
    op.drop_column('cmf_stock_move', 'system')
    op.drop_column('cmf_stock_items', 'system')
    op.drop_column('cmf_stock', 'system')
    op.drop_column('cmf_status_opt', 'system')
    op.drop_column('cmf_staff_control_settings', 'system')
    op.drop_column('cmf_staff_control', 'system')
    op.drop_column('cmf_sales_order_items', 'system')
    op.drop_column('cmf_sales_order', 'system')
    op.drop_column('cmf_role', 'system')
    op.drop_column('cmf_purchase_order_items', 'system')
    op.drop_column('cmf_purchase_order', 'system')
    op.drop_column('cmf_project', 'system')
    op.drop_column('cmf_product', 'system')
    op.drop_column('cmf_print_tmpl', 'system')
    op.drop_column('cmf_price', 'system')
    op.drop_column('cmf_plan', 'system')
    op.drop_column('cmf_pipeline', 'system')
    op.drop_column('cmf_person_group', 'system')
    op.drop_column('cmf_person', 'system')
    op.drop_column('cmf_payment', 'system')
    op.drop_column('cmf_org_unit', 'system')
    op.drop_column('cmf_notify', 'system')
    op.drop_column('cmf_mailbox', 'system')
    op.drop_column('cmf_mail_template', 'system')
    op.drop_column('cmf_mail_signature', 'system')
    op.drop_column('cmf_mail', 'system')
    op.drop_column('cmf_list', 'system')
    op.drop_column('cmf_lead', 'system')
    op.drop_column('cmf_job', 'system')
    op.drop_column('cmf_invoice_items', 'system')
    op.drop_column('cmf_invoice', 'system')
    op.drop_column('cmf_integration', 'system')
    op.drop_column('cmf_import', 'system')
    op.drop_column('cmf_form_field', 'system')
    op.drop_column('cmf_form', 'system')
    op.drop_column('cmf_folder', 'system')
    op.drop_column('cmf_feed', 'system')
    op.drop_column('cmf_document', 'system')
    op.drop_column('cmf_deal', 'system')
    op.drop_column('cmf_currency', 'system')
    op.drop_column('cmf_company', 'system')
    op.drop_column('cmf_comment', 'system')
    op.drop_column('cmf_chat_topic', 'system')
    op.drop_column('cmf_chat_group', 'system')
    op.drop_column('cmf_channel_message', 'system')
    op.drop_column('cmf_card', 'system')
    op.drop_column('cmf_balance_operation', 'system')
    op.drop_column('cmf_balance', 'system')
    op.drop_column('cmf_attachment', 'system')
    op.drop_column('cmf_activity', 'system')
    op.drop_column('cmf_active_entity_filter', 'system')
    # ### end Alembic commands ###
