"""empty message

Revision ID: 3e33cc123e7e
Revises: b907bf43b4b9
Create Date: 2020-12-30 11:44:23.097399

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '3e33cc123e7e'
down_revision = 'b907bf43b4b9'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_balance',
    sa.Column('balance_cache', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('credit', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('debit', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('start_balance', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_balance_cmf_author_id'), 'cmf_balance', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_created_at'), 'cmf_balance', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_deleted'), 'cmf_balance', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_locked_at'), 'cmf_balance', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_locked_by_id'), 'cmf_balance', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_modified_at'), 'cmf_balance', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_modified_by_id'), 'cmf_balance', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_owner_id'), 'cmf_balance', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_version'), 'cmf_balance', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_balance_cmf_viewed_at'), 'cmf_balance', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_code'), 'cmf_balance', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_balance_name'), 'cmf_balance', ['name'], unique=False)
    op.create_table('cmf_balance_operation',
    sa.Column('balance_end', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('balance_start', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('credit', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('debit', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('document_id', 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('text', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_balance_operation_cmf_author_id'), 'cmf_balance_operation', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_created_at'), 'cmf_balance_operation', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_deleted'), 'cmf_balance_operation', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_locked_at'), 'cmf_balance_operation', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_locked_by_id'), 'cmf_balance_operation', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_modified_at'), 'cmf_balance_operation', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_modified_by_id'), 'cmf_balance_operation', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_owner_id'), 'cmf_balance_operation', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_version'), 'cmf_balance_operation', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_cmf_viewed_at'), 'cmf_balance_operation', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_code'), 'cmf_balance_operation', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_balance_operation_document_id'), 'cmf_balance_operation', ['document_id'], unique=False)
    op.create_index(op.f('ix_cmf_balance_operation_name'), 'cmf_balance_operation', ['name'], unique=False)
    op.create_table('cmf_purchase_order_executors',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_executors_left_id'), 'cmf_purchase_order_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_executors_parent_id'), 'cmf_purchase_order_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_executors_right_id'), 'cmf_purchase_order_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_executors_root_id'), 'cmf_purchase_order_executors', ['root_id'], unique=False)
    op.create_table('cmf_purchase_order_items_executors',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_items_executors_left_id'), 'cmf_purchase_order_items_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_executors_parent_id'), 'cmf_purchase_order_items_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_executors_right_id'), 'cmf_purchase_order_items_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_executors_root_id'), 'cmf_purchase_order_items_executors', ['root_id'], unique=False)
    op.create_table('cmf_purchase_order_items_related_objects',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_items_related_objects_left_id'), 'cmf_purchase_order_items_related_objects', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_related_objects_parent_id'), 'cmf_purchase_order_items_related_objects', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_related_objects_right_id'), 'cmf_purchase_order_items_related_objects', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_related_objects_root_id'), 'cmf_purchase_order_items_related_objects', ['root_id'], unique=False)
    op.create_table('cmf_purchase_order_items_spectators',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_items_spectators_left_id'), 'cmf_purchase_order_items_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_spectators_parent_id'), 'cmf_purchase_order_items_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_spectators_right_id'), 'cmf_purchase_order_items_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_spectators_root_id'), 'cmf_purchase_order_items_spectators', ['root_id'], unique=False)
    op.create_table('cmf_purchase_order_related_objects',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_related_objects_left_id'), 'cmf_purchase_order_related_objects', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_related_objects_parent_id'), 'cmf_purchase_order_related_objects', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_related_objects_right_id'), 'cmf_purchase_order_related_objects', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_related_objects_root_id'), 'cmf_purchase_order_related_objects', ['root_id'], unique=False)
    op.create_table('cmf_purchase_order_spectators',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_spectators_left_id'), 'cmf_purchase_order_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_spectators_parent_id'), 'cmf_purchase_order_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_spectators_right_id'), 'cmf_purchase_order_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_spectators_root_id'), 'cmf_purchase_order_spectators', ['root_id'], unique=False)
    op.create_table('cmf_stock',
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('text', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_cmf_author_id'), 'cmf_stock', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_created_at'), 'cmf_stock', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_deleted'), 'cmf_stock', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_locked_at'), 'cmf_stock', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_locked_by_id'), 'cmf_stock', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_modified_at'), 'cmf_stock', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_modified_by_id'), 'cmf_stock', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_owner_id'), 'cmf_stock', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_version'), 'cmf_stock', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_stock_cmf_viewed_at'), 'cmf_stock', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_code'), 'cmf_stock', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_stock_name'), 'cmf_stock', ['name'], unique=False)
    op.create_table('cmf_stock_move_executors',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_executors_left_id'), 'cmf_stock_move_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_executors_parent_id'), 'cmf_stock_move_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_executors_right_id'), 'cmf_stock_move_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_executors_root_id'), 'cmf_stock_move_executors', ['root_id'], unique=False)
    op.create_table('cmf_stock_move_items_executors',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_items_executors_left_id'), 'cmf_stock_move_items_executors', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_executors_parent_id'), 'cmf_stock_move_items_executors', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_executors_right_id'), 'cmf_stock_move_items_executors', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_executors_root_id'), 'cmf_stock_move_items_executors', ['root_id'], unique=False)
    op.create_table('cmf_stock_move_items_related_objects',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_items_related_objects_left_id'), 'cmf_stock_move_items_related_objects', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_related_objects_parent_id'), 'cmf_stock_move_items_related_objects', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_related_objects_right_id'), 'cmf_stock_move_items_related_objects', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_related_objects_root_id'), 'cmf_stock_move_items_related_objects', ['root_id'], unique=False)
    op.create_table('cmf_stock_move_items_spectators',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_items_spectators_left_id'), 'cmf_stock_move_items_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_spectators_parent_id'), 'cmf_stock_move_items_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_spectators_right_id'), 'cmf_stock_move_items_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_spectators_root_id'), 'cmf_stock_move_items_spectators', ['root_id'], unique=False)
    op.create_table('cmf_stock_move_related_objects',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_related_objects_left_id'), 'cmf_stock_move_related_objects', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_related_objects_parent_id'), 'cmf_stock_move_related_objects', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_related_objects_right_id'), 'cmf_stock_move_related_objects', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_related_objects_root_id'), 'cmf_stock_move_related_objects', ['root_id'], unique=False)
    op.create_table('cmf_stock_move_spectators',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.Column('root_id', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_spectators_left_id'), 'cmf_stock_move_spectators', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_spectators_parent_id'), 'cmf_stock_move_spectators', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_spectators_right_id'), 'cmf_stock_move_spectators', ['right_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_spectators_root_id'), 'cmf_stock_move_spectators', ['root_id'], unique=False)
    op.create_table('cmf_stock_operations',
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('count', sa.Integer(), nullable=True),
    sa.Column('document_id', 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('stock_in_count_end', sa.Integer(), nullable=True),
    sa.Column('stock_in_id', sa.String(length=64), nullable=True),
    sa.Column('stock_out_count_end', sa.Integer(), nullable=True),
    sa.Column('stock_out_id', sa.String(length=64), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.ForeignKeyConstraint(['stock_in_id'], ['cmf_stock.id'], ),
    sa.ForeignKeyConstraint(['stock_out_id'], ['cmf_stock.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_operations_cmf_author_id'), 'cmf_stock_operations', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_created_at'), 'cmf_stock_operations', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_deleted'), 'cmf_stock_operations', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_locked_at'), 'cmf_stock_operations', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_locked_by_id'), 'cmf_stock_operations', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_modified_at'), 'cmf_stock_operations', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_modified_by_id'), 'cmf_stock_operations', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_owner_id'), 'cmf_stock_operations', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_version'), 'cmf_stock_operations', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_cmf_viewed_at'), 'cmf_stock_operations', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_code'), 'cmf_stock_operations', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_stock_operations_document_id'), 'cmf_stock_operations', ['document_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_name'), 'cmf_stock_operations', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_stock_in_id'), 'cmf_stock_operations', ['stock_in_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_operations_stock_out_id'), 'cmf_stock_operations', ['stock_out_id'], unique=False)
    op.create_table('cmf_purchase_order',
    sa.Column('activity_id', sa.String(length=64), nullable=True),
    sa.Column('alarm_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cache_status_type', sa.String(length=32), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('company_id', sa.String(length=64), nullable=True),
    sa.Column('currency_id', sa.String(length=64), nullable=True),
    sa.Column('deadline', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('is_penalty', sa.Boolean(), nullable=True),
    sa.Column('mark', sa.String(length=32), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('no_control', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('parent_task_id', sa.String(length=64), nullable=True),
    sa.Column('period_clone_from_id', sa.String(length=64), nullable=True),
    sa.Column('period_interval', sa.String(length=32), nullable=True),
    sa.Column('period_next_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_end_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('priority', sa.String(length=32), nullable=False),
    sa.Column('project_id', sa.String(length=64), nullable=True),
    sa.Column('responsible_id', sa.String(length=64), nullable=True),
    sa.Column('status_id', sa.String(length=64), nullable=True),
    sa.Column('status_modified_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('stock_id', sa.String(length=64), nullable=True),
    sa.Column('tags', sa.TEXT(), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('time_estimate', sa.Integer(), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('waiting_for_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['activity_id'], ['cmf_activity.id'], ),
    sa.ForeignKeyConstraint(['company_id'], ['cmf_company.id'], ),
    sa.ForeignKeyConstraint(['currency_id'], ['cmf_currency.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.ForeignKeyConstraint(['status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['stock_id'], ['cmf_stock.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_activity_id'), 'cmf_purchase_order', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_alarm_date'), 'cmf_purchase_order', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cache_status_type'), 'cmf_purchase_order', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_author_id'), 'cmf_purchase_order', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_created_at'), 'cmf_purchase_order', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_deleted'), 'cmf_purchase_order', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_locked_at'), 'cmf_purchase_order', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_locked_by_id'), 'cmf_purchase_order', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_modified_at'), 'cmf_purchase_order', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_modified_by_id'), 'cmf_purchase_order', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_owner_id'), 'cmf_purchase_order', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_version'), 'cmf_purchase_order', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_cmf_viewed_at'), 'cmf_purchase_order', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_code'), 'cmf_purchase_order', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_purchase_order_company_id'), 'cmf_purchase_order', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_currency_id'), 'cmf_purchase_order', ['currency_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_name'), 'cmf_purchase_order', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_orderno'), 'cmf_purchase_order', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_parent_task_id'), 'cmf_purchase_order', ['parent_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_period_clone_from_id'), 'cmf_purchase_order', ['period_clone_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_project_id'), 'cmf_purchase_order', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_responsible_id'), 'cmf_purchase_order', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_status_id'), 'cmf_purchase_order', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_stock_id'), 'cmf_purchase_order', ['stock_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_tree_parent_id'), 'cmf_purchase_order', ['tree_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_waiting_for_id'), 'cmf_purchase_order', ['waiting_for_id'], unique=False)
    op.create_table('cmf_stock_items',
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('cost', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.Column('direct_costs', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('margin', sa.Integer(), nullable=True),
    sa.Column('margin_pct', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('product_id', sa.String(length=64), nullable=True),
    sa.Column('series', sa.String(length=32), nullable=True),
    sa.Column('stock_id', sa.String(length=64), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('unit_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['product_id'], ['cmf_product.id'], ),
    sa.ForeignKeyConstraint(['stock_id'], ['cmf_stock.id'], ),
    sa.ForeignKeyConstraint(['unit_id'], ['cmf_unit.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_items_cmf_author_id'), 'cmf_stock_items', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_created_at'), 'cmf_stock_items', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_deleted'), 'cmf_stock_items', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_locked_at'), 'cmf_stock_items', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_locked_by_id'), 'cmf_stock_items', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_modified_at'), 'cmf_stock_items', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_modified_by_id'), 'cmf_stock_items', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_owner_id'), 'cmf_stock_items', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_version'), 'cmf_stock_items', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_cmf_viewed_at'), 'cmf_stock_items', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_code'), 'cmf_stock_items', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_stock_items_name'), 'cmf_stock_items', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_product_id'), 'cmf_stock_items', ['product_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_stock_id'), 'cmf_stock_items', ['stock_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_items_unit_id'), 'cmf_stock_items', ['unit_id'], unique=False)
    op.create_table('cmf_stock_move',
    sa.Column('activity_id', sa.String(length=64), nullable=True),
    sa.Column('alarm_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cache_status_type', sa.String(length=32), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('company_id', sa.String(length=64), nullable=True),
    sa.Column('deadline', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('is_penalty', sa.Boolean(), nullable=True),
    sa.Column('mark', sa.String(length=32), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('no_control', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('parent_task_id', sa.String(length=64), nullable=True),
    sa.Column('period_clone_from_id', sa.String(length=64), nullable=True),
    sa.Column('period_interval', sa.String(length=32), nullable=True),
    sa.Column('period_next_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_end_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('priority', sa.String(length=32), nullable=False),
    sa.Column('project_id', sa.String(length=64), nullable=True),
    sa.Column('responsible_id', sa.String(length=64), nullable=True),
    sa.Column('status_id', sa.String(length=64), nullable=True),
    sa.Column('status_modified_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('stock_in_id', sa.String(length=64), nullable=True),
    sa.Column('stock_out_id', sa.String(length=64), nullable=True),
    sa.Column('tags', sa.TEXT(), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('time_estimate', sa.Integer(), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('waiting_for_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['activity_id'], ['cmf_activity.id'], ),
    sa.ForeignKeyConstraint(['company_id'], ['cmf_company.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.ForeignKeyConstraint(['status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['stock_in_id'], ['cmf_stock.id'], ),
    sa.ForeignKeyConstraint(['stock_out_id'], ['cmf_stock.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_activity_id'), 'cmf_stock_move', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_alarm_date'), 'cmf_stock_move', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cache_status_type'), 'cmf_stock_move', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_author_id'), 'cmf_stock_move', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_created_at'), 'cmf_stock_move', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_deleted'), 'cmf_stock_move', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_locked_at'), 'cmf_stock_move', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_locked_by_id'), 'cmf_stock_move', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_modified_at'), 'cmf_stock_move', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_modified_by_id'), 'cmf_stock_move', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_owner_id'), 'cmf_stock_move', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_version'), 'cmf_stock_move', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_cmf_viewed_at'), 'cmf_stock_move', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_code'), 'cmf_stock_move', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_stock_move_company_id'), 'cmf_stock_move', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_name'), 'cmf_stock_move', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_orderno'), 'cmf_stock_move', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_parent_task_id'), 'cmf_stock_move', ['parent_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_period_clone_from_id'), 'cmf_stock_move', ['period_clone_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_project_id'), 'cmf_stock_move', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_responsible_id'), 'cmf_stock_move', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_status_id'), 'cmf_stock_move', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_stock_in_id'), 'cmf_stock_move', ['stock_in_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_stock_out_id'), 'cmf_stock_move', ['stock_out_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_tree_parent_id'), 'cmf_stock_move', ['tree_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_waiting_for_id'), 'cmf_stock_move', ['waiting_for_id'], unique=False)
    op.create_table('cmf_purchase_order_items',
    sa.Column('activity_id', sa.String(length=64), nullable=True),
    sa.Column('alarm_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cache_status_type', sa.String(length=32), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('company_id', sa.String(length=64), nullable=True),
    sa.Column('cost', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.Column('deadline', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('direct_costs', sa.Numeric(precision=14, scale=2), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('is_penalty', sa.Boolean(), nullable=True),
    sa.Column('margin', sa.Integer(), nullable=True),
    sa.Column('margin_pct', sa.Integer(), nullable=True),
    sa.Column('mark', sa.String(length=32), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('no_control', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('parent_task_id', sa.String(length=64), nullable=True),
    sa.Column('period_clone_from_id', sa.String(length=64), nullable=True),
    sa.Column('period_interval', sa.String(length=32), nullable=True),
    sa.Column('period_next_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_end_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('priority', sa.String(length=32), nullable=False),
    sa.Column('product_id', sa.String(length=64), nullable=True),
    sa.Column('project_id', sa.String(length=64), nullable=True),
    sa.Column('purchase_order_id', sa.String(length=64), nullable=True),
    sa.Column('responsible_id', sa.String(length=64), nullable=True),
    sa.Column('series', sa.String(length=32), nullable=True),
    sa.Column('status_id', sa.String(length=64), nullable=True),
    sa.Column('status_modified_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('tags', sa.TEXT(), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('time_estimate', sa.Integer(), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('unit_id', sa.String(length=64), nullable=True),
    sa.Column('waiting_for_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['activity_id'], ['cmf_activity.id'], ),
    sa.ForeignKeyConstraint(['company_id'], ['cmf_company.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['cmf_product.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.ForeignKeyConstraint(['purchase_order_id'], ['cmf_purchase_order.id'], ),
    sa.ForeignKeyConstraint(['status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['unit_id'], ['cmf_unit.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_purchase_order_items_activity_id'), 'cmf_purchase_order_items', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_alarm_date'), 'cmf_purchase_order_items', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cache_status_type'), 'cmf_purchase_order_items', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_author_id'), 'cmf_purchase_order_items', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_created_at'), 'cmf_purchase_order_items', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_deleted'), 'cmf_purchase_order_items', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_locked_at'), 'cmf_purchase_order_items', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_locked_by_id'), 'cmf_purchase_order_items', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_modified_at'), 'cmf_purchase_order_items', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_modified_by_id'), 'cmf_purchase_order_items', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_owner_id'), 'cmf_purchase_order_items', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_version'), 'cmf_purchase_order_items', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_cmf_viewed_at'), 'cmf_purchase_order_items', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_code'), 'cmf_purchase_order_items', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_purchase_order_items_company_id'), 'cmf_purchase_order_items', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_name'), 'cmf_purchase_order_items', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_orderno'), 'cmf_purchase_order_items', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_parent_task_id'), 'cmf_purchase_order_items', ['parent_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_period_clone_from_id'), 'cmf_purchase_order_items', ['period_clone_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_product_id'), 'cmf_purchase_order_items', ['product_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_project_id'), 'cmf_purchase_order_items', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_purchase_order_id'), 'cmf_purchase_order_items', ['purchase_order_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_responsible_id'), 'cmf_purchase_order_items', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_status_id'), 'cmf_purchase_order_items', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_tree_parent_id'), 'cmf_purchase_order_items', ['tree_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_unit_id'), 'cmf_purchase_order_items', ['unit_id'], unique=False)
    op.create_index(op.f('ix_cmf_purchase_order_items_waiting_for_id'), 'cmf_purchase_order_items', ['waiting_for_id'], unique=False)
    op.create_table('cmf_stock_move_items',
    sa.Column('activity_id', sa.String(length=64), nullable=True),
    sa.Column('alarm_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cache_status_type', sa.String(length=32), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=True),
    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=True),
    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('company_id', sa.String(length=64), nullable=True),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.Column('deadline', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('is_penalty', sa.Boolean(), nullable=True),
    sa.Column('mark', sa.String(length=32), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=True),
    sa.Column('no_control', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('parent_task_id', sa.String(length=64), nullable=True),
    sa.Column('period_clone_from_id', sa.String(length=64), nullable=True),
    sa.Column('period_interval', sa.String(length=32), nullable=True),
    sa.Column('period_next_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_end_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('plan_start_date', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('priority', sa.String(length=32), nullable=False),
    sa.Column('product_id', sa.String(length=64), nullable=True),
    sa.Column('project_id', sa.String(length=64), nullable=True),
    sa.Column('responsible_id', sa.String(length=64), nullable=True),
    sa.Column('status_id', sa.String(length=64), nullable=True),
    sa.Column('status_modified_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('stock_move_id', sa.String(length=64), nullable=True),
    sa.Column('tags', sa.TEXT(), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('time_estimate', sa.Integer(), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('unit_id', sa.String(length=64), nullable=True),
    sa.Column('waiting_for_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['activity_id'], ['cmf_activity.id'], ),
    sa.ForeignKeyConstraint(['company_id'], ['cmf_company.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['cmf_product.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.ForeignKeyConstraint(['status_id'], ['cmf_status.id'], ),
    sa.ForeignKeyConstraint(['stock_move_id'], ['cmf_stock_move.id'], ),
    sa.ForeignKeyConstraint(['unit_id'], ['cmf_unit.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_stock_move_items_activity_id'), 'cmf_stock_move_items', ['activity_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_alarm_date'), 'cmf_stock_move_items', ['alarm_date'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cache_status_type'), 'cmf_stock_move_items', ['cache_status_type'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_author_id'), 'cmf_stock_move_items', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_created_at'), 'cmf_stock_move_items', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_deleted'), 'cmf_stock_move_items', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_locked_at'), 'cmf_stock_move_items', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_locked_by_id'), 'cmf_stock_move_items', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_modified_at'), 'cmf_stock_move_items', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_modified_by_id'), 'cmf_stock_move_items', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_owner_id'), 'cmf_stock_move_items', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_version'), 'cmf_stock_move_items', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_cmf_viewed_at'), 'cmf_stock_move_items', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_code'), 'cmf_stock_move_items', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_stock_move_items_company_id'), 'cmf_stock_move_items', ['company_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_name'), 'cmf_stock_move_items', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_orderno'), 'cmf_stock_move_items', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_parent_task_id'), 'cmf_stock_move_items', ['parent_task_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_period_clone_from_id'), 'cmf_stock_move_items', ['period_clone_from_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_product_id'), 'cmf_stock_move_items', ['product_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_project_id'), 'cmf_stock_move_items', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_responsible_id'), 'cmf_stock_move_items', ['responsible_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_status_id'), 'cmf_stock_move_items', ['status_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_stock_move_id'), 'cmf_stock_move_items', ['stock_move_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_tree_parent_id'), 'cmf_stock_move_items', ['tree_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_unit_id'), 'cmf_stock_move_items', ['unit_id'], unique=False)
    op.create_index(op.f('ix_cmf_stock_move_items_waiting_for_id'), 'cmf_stock_move_items', ['waiting_for_id'], unique=False)
    op.create_table('cmf_lead_cmf_person',
    sa.Column('description', sa.String(length=4096), nullable=True),
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('left_id', sa.String(length=64), nullable=True),
    sa.Column('left_name_cache', sa.String(length=256), nullable=True),
    sa.Column('right_id', sa.String(length=64), nullable=True),
    sa.Column('right_name_cache', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['left_id'], ['cmf_lead.id'], ),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_person.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_lead_cmf_person_left_id'), 'cmf_lead_cmf_person', ['left_id'], unique=False)
    op.create_index(op.f('ix_cmf_lead_cmf_person_right_id'), 'cmf_lead_cmf_person', ['right_id'], unique=False)
    op.drop_index('ix_cmf_deal_cmf_company_left_id', table_name='cmf_deal_cmf_company')
    op.drop_index('ix_cmf_deal_cmf_company_right_id', table_name='cmf_deal_cmf_company')
    op.drop_table('cmf_deal_cmf_company')
    op.add_column('cmf_deal', sa.Column('discount', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_deal', sa.Column('discount_pct', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_deal', sa.Column('lead_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_deal_lead_id'), 'cmf_deal', ['lead_id'], unique=False)
    op.create_foreign_key(None, 'cmf_deal', 'cmf_lead', ['lead_id'], ['id'])
    op.add_column('cmf_invoice', sa.Column('discount_pct', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_invoice', sa.Column('sales_order_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_invoice_sales_order_id'), 'cmf_invoice', ['sales_order_id'], unique=False)
    op.drop_index('ix_cmf_invoice_customer_id', table_name='cmf_invoice')
    op.drop_index('ix_cmf_invoice_print_tmpl_id', table_name='cmf_invoice')
    op.drop_constraint('cmf_invoice_print_tmpl_id_fkey', 'cmf_invoice', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_invoice', 'cmf_sales_order', ['sales_order_id'], ['id'])
    op.drop_column('cmf_invoice', 'customer_id')
    op.drop_column('cmf_invoice', 'print_tmpl_id')
    op.add_column('cmf_lead', sa.Column('ga_step', sa.String(length=32), nullable=True))
    op.add_column('cmf_lead', sa.Column('http_referrer', sa.String(length=32), nullable=True))
    op.add_column('cmf_lead', sa.Column('http_user_agent', sa.String(length=32), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_company_name', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_contact_name', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_cookieid', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_email_name', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_form_url', sa.String(length=32), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_google_clientid', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_google_userid', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_ip', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_phone_name', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_product_name', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_touch_url', sa.String(length=32), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_yandex_clientid', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('lead_yandex_userid', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('pipeline_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_lead', sa.Column('utm_campaign', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('utm_medium', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('utm_query', sa.TEXT(), nullable=True))
    op.add_column('cmf_lead', sa.Column('utm_referrer', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('utm_source', sa.String(length=256), nullable=True))
    op.add_column('cmf_lead', sa.Column('utm_term', sa.String(length=256), nullable=True))
    op.create_index(op.f('ix_cmf_lead_pipeline_id'), 'cmf_lead', ['pipeline_id'], unique=False)
    op.create_foreign_key(None, 'cmf_lead', 'cmf_pipeline', ['pipeline_id'], ['id'])
    op.drop_column('cmf_lead', 'utm_mark')
    op.add_column('cmf_payment', sa.Column('summa', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_payment', sa.Column('type', sa.String(length=32), nullable=True))
    op.drop_index('ix_cmf_payment_customer_id', table_name='cmf_payment')
    op.drop_index('ix_cmf_payment_print_tmpl_id', table_name='cmf_payment')
    op.drop_constraint('cmf_payment_print_tmpl_id_fkey', 'cmf_payment', type_='foreignkey')
    op.drop_column('cmf_payment', 'customer_id')
    op.drop_column('cmf_payment', 'print_tmpl_id')
    op.add_column('cmf_price', sa.Column('margin', sa.Integer(), nullable=True))
    op.add_column('cmf_price', sa.Column('margin_pct', sa.Integer(), nullable=True))
    op.add_column('cmf_price', sa.Column('profit', sa.Integer(), nullable=True))
    op.add_column('cmf_price', sa.Column('start_date', sa.TIMESTAMP(timezone=True), nullable=True))
    op.drop_index('ix_cmf_price_unit_id', table_name='cmf_price')
    op.drop_constraint('cmf_price_unit_id_fkey', 'cmf_price', type_='foreignkey')
    op.drop_column('cmf_price', 'unit_id')
    op.add_column('cmf_print_tmpl', sa.Column('cmf_model', sa.String(length=256), nullable=True))
    op.add_column('cmf_product', sa.Column('unit_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_product_unit_id'), 'cmf_product', ['unit_id'], unique=False)
    op.create_foreign_key(None, 'cmf_product', 'cmf_unit', ['unit_id'], ['id'])
    op.add_column('cmf_sales_order', sa.Column('discount_pct', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_sales_order', sa.Column('stock_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_sales_order_stock_id'), 'cmf_sales_order', ['stock_id'], unique=False)
    op.drop_index('ix_cmf_sales_order_customer_id', table_name='cmf_sales_order')
    op.drop_index('ix_cmf_sales_order_print_tmpl_id', table_name='cmf_sales_order')
    op.drop_constraint('cmf_sales_order_print_tmpl_id_fkey', 'cmf_sales_order', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_sales_order', 'cmf_stock', ['stock_id'], ['id'])
    op.drop_column('cmf_sales_order', 'customer_id')
    op.drop_column('cmf_sales_order', 'print_tmpl_id')
    op.add_column('cmf_sales_order_items', sa.Column('discount', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_sales_order_items', sa.Column('discount_pct', sa.Numeric(precision=14, scale=2), nullable=True))
    op.add_column('cmf_sales_order_items', sa.Column('name_cache', sa.String(length=256), nullable=True))
    op.add_column('cmf_sales_order_items', sa.Column('sales_order_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_sales_order_items', sa.Column('unit_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_sales_order_items_name'), 'cmf_sales_order_items', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_sales_order_items_sales_order_id'), 'cmf_sales_order_items', ['sales_order_id'], unique=False)
    op.create_index(op.f('ix_cmf_sales_order_items_unit_id'), 'cmf_sales_order_items', ['unit_id'], unique=False)
    op.drop_index('ix_cmf_sales_order_items_deal_id', table_name='cmf_sales_order_items')
    op.drop_constraint('cmf_sales_order_items_deal_id_fkey', 'cmf_sales_order_items', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_sales_order_items', 'cmf_unit', ['unit_id'], ['id'])
    op.create_foreign_key(None, 'cmf_sales_order_items', 'cmf_sales_order', ['sales_order_id'], ['id'])
    op.drop_column('cmf_sales_order_items', 'deal_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_sales_order_items', sa.Column('deal_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_sales_order_items', type_='foreignkey')
    op.drop_constraint(None, 'cmf_sales_order_items', type_='foreignkey')
    op.create_foreign_key('cmf_sales_order_items_deal_id_fkey', 'cmf_sales_order_items', 'cmf_deal', ['deal_id'], ['id'])
    op.create_index('ix_cmf_sales_order_items_deal_id', 'cmf_sales_order_items', ['deal_id'], unique=False)
    op.drop_index(op.f('ix_cmf_sales_order_items_unit_id'), table_name='cmf_sales_order_items')
    op.drop_index(op.f('ix_cmf_sales_order_items_sales_order_id'), table_name='cmf_sales_order_items')
    op.drop_index(op.f('ix_cmf_sales_order_items_name'), table_name='cmf_sales_order_items')
    op.drop_column('cmf_sales_order_items', 'unit_id')
    op.drop_column('cmf_sales_order_items', 'sales_order_id')
    op.drop_column('cmf_sales_order_items', 'name_cache')
    op.drop_column('cmf_sales_order_items', 'discount_pct')
    op.drop_column('cmf_sales_order_items', 'discount')
    op.add_column('cmf_sales_order', sa.Column('print_tmpl_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_sales_order', sa.Column('customer_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_sales_order', type_='foreignkey')
    op.create_foreign_key('cmf_sales_order_print_tmpl_id_fkey', 'cmf_sales_order', 'cmf_print_tmpl', ['print_tmpl_id'], ['id'])
    op.create_index('ix_cmf_sales_order_print_tmpl_id', 'cmf_sales_order', ['print_tmpl_id'], unique=False)
    op.create_index('ix_cmf_sales_order_customer_id', 'cmf_sales_order', ['customer_id'], unique=False)
    op.drop_index(op.f('ix_cmf_sales_order_stock_id'), table_name='cmf_sales_order')
    op.drop_column('cmf_sales_order', 'stock_id')
    op.drop_column('cmf_sales_order', 'discount_pct')
    op.drop_constraint(None, 'cmf_product', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_product_unit_id'), table_name='cmf_product')
    op.drop_column('cmf_product', 'unit_id')
    op.drop_column('cmf_print_tmpl', 'cmf_model')
    op.add_column('cmf_price', sa.Column('unit_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.create_foreign_key('cmf_price_unit_id_fkey', 'cmf_price', 'cmf_unit', ['unit_id'], ['id'])
    op.create_index('ix_cmf_price_unit_id', 'cmf_price', ['unit_id'], unique=False)
    op.drop_column('cmf_price', 'start_date')
    op.drop_column('cmf_price', 'profit')
    op.drop_column('cmf_price', 'margin_pct')
    op.drop_column('cmf_price', 'margin')
    op.add_column('cmf_payment', sa.Column('print_tmpl_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_payment', sa.Column('customer_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.create_foreign_key('cmf_payment_print_tmpl_id_fkey', 'cmf_payment', 'cmf_print_tmpl', ['print_tmpl_id'], ['id'])
    op.create_index('ix_cmf_payment_print_tmpl_id', 'cmf_payment', ['print_tmpl_id'], unique=False)
    op.create_index('ix_cmf_payment_customer_id', 'cmf_payment', ['customer_id'], unique=False)
    op.drop_column('cmf_payment', 'type')
    op.drop_column('cmf_payment', 'summa')
    op.add_column('cmf_lead', sa.Column('utm_mark', sa.TEXT(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_lead', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_lead_pipeline_id'), table_name='cmf_lead')
    op.drop_column('cmf_lead', 'utm_term')
    op.drop_column('cmf_lead', 'utm_source')
    op.drop_column('cmf_lead', 'utm_referrer')
    op.drop_column('cmf_lead', 'utm_query')
    op.drop_column('cmf_lead', 'utm_medium')
    op.drop_column('cmf_lead', 'utm_campaign')
    op.drop_column('cmf_lead', 'pipeline_id')
    op.drop_column('cmf_lead', 'lead_yandex_userid')
    op.drop_column('cmf_lead', 'lead_yandex_clientid')
    op.drop_column('cmf_lead', 'lead_touch_url')
    op.drop_column('cmf_lead', 'lead_product_name')
    op.drop_column('cmf_lead', 'lead_phone_name')
    op.drop_column('cmf_lead', 'lead_ip')
    op.drop_column('cmf_lead', 'lead_google_userid')
    op.drop_column('cmf_lead', 'lead_google_clientid')
    op.drop_column('cmf_lead', 'lead_form_url')
    op.drop_column('cmf_lead', 'lead_email_name')
    op.drop_column('cmf_lead', 'lead_cookieid')
    op.drop_column('cmf_lead', 'lead_contact_name')
    op.drop_column('cmf_lead', 'lead_company_name')
    op.drop_column('cmf_lead', 'http_user_agent')
    op.drop_column('cmf_lead', 'http_referrer')
    op.drop_column('cmf_lead', 'ga_step')
    op.add_column('cmf_invoice', sa.Column('print_tmpl_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_invoice', sa.Column('customer_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_invoice', type_='foreignkey')
    op.create_foreign_key('cmf_invoice_print_tmpl_id_fkey', 'cmf_invoice', 'cmf_print_tmpl', ['print_tmpl_id'], ['id'])
    op.create_index('ix_cmf_invoice_print_tmpl_id', 'cmf_invoice', ['print_tmpl_id'], unique=False)
    op.create_index('ix_cmf_invoice_customer_id', 'cmf_invoice', ['customer_id'], unique=False)
    op.drop_index(op.f('ix_cmf_invoice_sales_order_id'), table_name='cmf_invoice')
    op.drop_column('cmf_invoice', 'sales_order_id')
    op.drop_column('cmf_invoice', 'discount_pct')
    op.drop_constraint(None, 'cmf_deal', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_deal_lead_id'), table_name='cmf_deal')
    op.drop_column('cmf_deal', 'lead_id')
    op.drop_column('cmf_deal', 'discount_pct')
    op.drop_column('cmf_deal', 'discount')
    op.create_table('cmf_deal_cmf_company',
    sa.Column('description', sa.VARCHAR(length=4096), autoincrement=False, nullable=True),
    sa.Column('id', sa.VARCHAR(length=64), 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('right_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('right_name_cache', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['left_id'], ['cmf_deal.id'], name='cmf_deal_cmf_company_left_id_fkey'),
    sa.ForeignKeyConstraint(['right_id'], ['cmf_company.id'], name='cmf_deal_cmf_company_right_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='cmf_deal_cmf_company_pkey')
    )
    op.create_index('ix_cmf_deal_cmf_company_right_id', 'cmf_deal_cmf_company', ['right_id'], unique=False)
    op.create_index('ix_cmf_deal_cmf_company_left_id', 'cmf_deal_cmf_company', ['left_id'], unique=False)
    op.drop_index(op.f('ix_cmf_lead_cmf_person_right_id'), table_name='cmf_lead_cmf_person')
    op.drop_index(op.f('ix_cmf_lead_cmf_person_left_id'), table_name='cmf_lead_cmf_person')
    op.drop_table('cmf_lead_cmf_person')
    op.drop_index(op.f('ix_cmf_stock_move_items_waiting_for_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_unit_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_tree_parent_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_stock_move_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_status_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_responsible_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_project_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_product_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_period_clone_from_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_parent_task_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_orderno'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_name'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_company_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_code'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_viewed_at'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_version'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_owner_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_modified_by_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_modified_at'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_locked_by_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_locked_at'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_deleted'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_created_at'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cmf_author_id'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_cache_status_type'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_alarm_date'), table_name='cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_stock_move_items_activity_id'), table_name='cmf_stock_move_items')
    op.drop_table('cmf_stock_move_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_waiting_for_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_unit_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_tree_parent_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_status_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_responsible_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_purchase_order_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_project_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_product_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_period_clone_from_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_parent_task_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_orderno'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_name'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_company_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_code'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_viewed_at'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_version'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_owner_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_modified_by_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_modified_at'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_locked_by_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_locked_at'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_deleted'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_created_at'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cmf_author_id'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_cache_status_type'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_alarm_date'), table_name='cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_purchase_order_items_activity_id'), table_name='cmf_purchase_order_items')
    op.drop_table('cmf_purchase_order_items')
    op.drop_index(op.f('ix_cmf_stock_move_waiting_for_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_tree_parent_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_stock_out_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_stock_in_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_status_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_responsible_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_project_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_period_clone_from_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_parent_task_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_orderno'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_name'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_company_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_code'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_viewed_at'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_version'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_owner_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_modified_by_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_modified_at'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_locked_by_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_locked_at'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_deleted'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_created_at'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cmf_author_id'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_cache_status_type'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_alarm_date'), table_name='cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_move_activity_id'), table_name='cmf_stock_move')
    op.drop_table('cmf_stock_move')
    op.drop_index(op.f('ix_cmf_stock_items_unit_id'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_stock_id'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_product_id'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_name'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_code'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_viewed_at'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_version'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_owner_id'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_modified_by_id'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_modified_at'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_locked_by_id'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_locked_at'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_deleted'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_created_at'), table_name='cmf_stock_items')
    op.drop_index(op.f('ix_cmf_stock_items_cmf_author_id'), table_name='cmf_stock_items')
    op.drop_table('cmf_stock_items')
    op.drop_index(op.f('ix_cmf_purchase_order_waiting_for_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_tree_parent_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_stock_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_status_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_responsible_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_project_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_period_clone_from_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_parent_task_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_orderno'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_name'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_currency_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_company_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_code'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_viewed_at'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_version'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_owner_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_modified_by_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_modified_at'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_locked_by_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_locked_at'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_deleted'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_created_at'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cmf_author_id'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_cache_status_type'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_alarm_date'), table_name='cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_purchase_order_activity_id'), table_name='cmf_purchase_order')
    op.drop_table('cmf_purchase_order')
    op.drop_index(op.f('ix_cmf_stock_operations_stock_out_id'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_stock_in_id'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_name'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_document_id'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_code'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_viewed_at'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_version'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_owner_id'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_modified_by_id'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_modified_at'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_locked_by_id'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_locked_at'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_deleted'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_created_at'), table_name='cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_operations_cmf_author_id'), table_name='cmf_stock_operations')
    op.drop_table('cmf_stock_operations')
    op.drop_index(op.f('ix_cmf_stock_move_spectators_root_id'), table_name='cmf_stock_move_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_spectators_right_id'), table_name='cmf_stock_move_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_spectators_parent_id'), table_name='cmf_stock_move_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_spectators_left_id'), table_name='cmf_stock_move_spectators')
    op.drop_table('cmf_stock_move_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_related_objects_root_id'), table_name='cmf_stock_move_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_related_objects_right_id'), table_name='cmf_stock_move_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_related_objects_parent_id'), table_name='cmf_stock_move_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_related_objects_left_id'), table_name='cmf_stock_move_related_objects')
    op.drop_table('cmf_stock_move_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_items_spectators_root_id'), table_name='cmf_stock_move_items_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_items_spectators_right_id'), table_name='cmf_stock_move_items_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_items_spectators_parent_id'), table_name='cmf_stock_move_items_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_items_spectators_left_id'), table_name='cmf_stock_move_items_spectators')
    op.drop_table('cmf_stock_move_items_spectators')
    op.drop_index(op.f('ix_cmf_stock_move_items_related_objects_root_id'), table_name='cmf_stock_move_items_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_items_related_objects_right_id'), table_name='cmf_stock_move_items_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_items_related_objects_parent_id'), table_name='cmf_stock_move_items_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_items_related_objects_left_id'), table_name='cmf_stock_move_items_related_objects')
    op.drop_table('cmf_stock_move_items_related_objects')
    op.drop_index(op.f('ix_cmf_stock_move_items_executors_root_id'), table_name='cmf_stock_move_items_executors')
    op.drop_index(op.f('ix_cmf_stock_move_items_executors_right_id'), table_name='cmf_stock_move_items_executors')
    op.drop_index(op.f('ix_cmf_stock_move_items_executors_parent_id'), table_name='cmf_stock_move_items_executors')
    op.drop_index(op.f('ix_cmf_stock_move_items_executors_left_id'), table_name='cmf_stock_move_items_executors')
    op.drop_table('cmf_stock_move_items_executors')
    op.drop_index(op.f('ix_cmf_stock_move_executors_root_id'), table_name='cmf_stock_move_executors')
    op.drop_index(op.f('ix_cmf_stock_move_executors_right_id'), table_name='cmf_stock_move_executors')
    op.drop_index(op.f('ix_cmf_stock_move_executors_parent_id'), table_name='cmf_stock_move_executors')
    op.drop_index(op.f('ix_cmf_stock_move_executors_left_id'), table_name='cmf_stock_move_executors')
    op.drop_table('cmf_stock_move_executors')
    op.drop_index(op.f('ix_cmf_stock_name'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_code'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_viewed_at'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_version'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_owner_id'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_modified_by_id'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_modified_at'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_locked_by_id'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_locked_at'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_deleted'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_created_at'), table_name='cmf_stock')
    op.drop_index(op.f('ix_cmf_stock_cmf_author_id'), table_name='cmf_stock')
    op.drop_table('cmf_stock')
    op.drop_index(op.f('ix_cmf_purchase_order_spectators_root_id'), table_name='cmf_purchase_order_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_spectators_right_id'), table_name='cmf_purchase_order_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_spectators_parent_id'), table_name='cmf_purchase_order_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_spectators_left_id'), table_name='cmf_purchase_order_spectators')
    op.drop_table('cmf_purchase_order_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_related_objects_root_id'), table_name='cmf_purchase_order_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_related_objects_right_id'), table_name='cmf_purchase_order_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_related_objects_parent_id'), table_name='cmf_purchase_order_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_related_objects_left_id'), table_name='cmf_purchase_order_related_objects')
    op.drop_table('cmf_purchase_order_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_items_spectators_root_id'), table_name='cmf_purchase_order_items_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_items_spectators_right_id'), table_name='cmf_purchase_order_items_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_items_spectators_parent_id'), table_name='cmf_purchase_order_items_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_items_spectators_left_id'), table_name='cmf_purchase_order_items_spectators')
    op.drop_table('cmf_purchase_order_items_spectators')
    op.drop_index(op.f('ix_cmf_purchase_order_items_related_objects_root_id'), table_name='cmf_purchase_order_items_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_items_related_objects_right_id'), table_name='cmf_purchase_order_items_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_items_related_objects_parent_id'), table_name='cmf_purchase_order_items_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_items_related_objects_left_id'), table_name='cmf_purchase_order_items_related_objects')
    op.drop_table('cmf_purchase_order_items_related_objects')
    op.drop_index(op.f('ix_cmf_purchase_order_items_executors_root_id'), table_name='cmf_purchase_order_items_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_items_executors_right_id'), table_name='cmf_purchase_order_items_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_items_executors_parent_id'), table_name='cmf_purchase_order_items_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_items_executors_left_id'), table_name='cmf_purchase_order_items_executors')
    op.drop_table('cmf_purchase_order_items_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_executors_root_id'), table_name='cmf_purchase_order_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_executors_right_id'), table_name='cmf_purchase_order_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_executors_parent_id'), table_name='cmf_purchase_order_executors')
    op.drop_index(op.f('ix_cmf_purchase_order_executors_left_id'), table_name='cmf_purchase_order_executors')
    op.drop_table('cmf_purchase_order_executors')
    op.drop_index(op.f('ix_cmf_balance_operation_name'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_document_id'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_code'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_viewed_at'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_version'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_owner_id'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_modified_by_id'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_modified_at'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_locked_by_id'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_locked_at'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_deleted'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_created_at'), table_name='cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_operation_cmf_author_id'), table_name='cmf_balance_operation')
    op.drop_table('cmf_balance_operation')
    op.drop_index(op.f('ix_cmf_balance_name'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_code'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_viewed_at'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_version'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_owner_id'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_modified_by_id'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_modified_at'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_locked_by_id'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_locked_at'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_deleted'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_created_at'), table_name='cmf_balance')
    op.drop_index(op.f('ix_cmf_balance_cmf_author_id'), table_name='cmf_balance')
    op.drop_table('cmf_balance')
    # ### end Alembic commands ###
