"""empty message

Revision ID: dbca0cce9093
Revises: 7ed56fdf83b4
Create Date: 2021-01-22 14:33:19.414969

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'dbca0cce9093'
down_revision = '7ed56fdf83b4'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_form_field',
    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('form_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('orderno', sa.Integer(), nullable=True),
    sa.Column('placeholder', sa.String(length=256), nullable=True),
    sa.Column('required', sa.Boolean(), nullable=True),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('type', sa.String(length=32), nullable=True),
    sa.Column('value', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['form_id'], ['cmf_form.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_form_field_cmf_author_id'), 'cmf_form_field', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_created_at'), 'cmf_form_field', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_deleted'), 'cmf_form_field', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_locked_at'), 'cmf_form_field', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_locked_by_id'), 'cmf_form_field', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_modified_at'), 'cmf_form_field', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_modified_by_id'), 'cmf_form_field', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_owner_id'), 'cmf_form_field', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_version'), 'cmf_form_field', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_cmf_viewed_at'), 'cmf_form_field', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_code'), 'cmf_form_field', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_form_field_form_id'), 'cmf_form_field', ['form_id'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_name'), 'cmf_form_field', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_form_field_orderno'), 'cmf_form_field', ['orderno'], unique=False)
    op.add_column('cmf_form', sa.Column('custom_css', sa.TEXT(), nullable=True))
    op.add_column('cmf_form', sa.Column('failure_text', sa.TEXT(), nullable=True))
    op.add_column('cmf_form', sa.Column('google_analytics', sa.String(length=64), nullable=True))
    op.add_column('cmf_form', sa.Column('roistat', sa.String(length=64), nullable=True))
    op.add_column('cmf_form', sa.Column('submit_text', sa.String(length=64), nullable=True))
    op.add_column('cmf_form', sa.Column('success_text', sa.TEXT(), nullable=True))
    op.add_column('cmf_form', sa.Column('title_text', sa.String(length=256), nullable=True))
    op.add_column('cmf_form', sa.Column('yandex_metrica', sa.String(length=64), nullable=True))
    op.drop_column('cmf_form', 'title')
    # Падает alembic upgrade
    # op.drop_index('ix_cmf_status_orderno', table_name='cmf_status')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index('ix_cmf_status_orderno', 'cmf_status', ['orderno'], unique=False)
    op.add_column('cmf_form', sa.Column('title', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_column('cmf_form', 'yandex_metrica')
    op.drop_column('cmf_form', 'title_text')
    op.drop_column('cmf_form', 'success_text')
    op.drop_column('cmf_form', 'submit_text')
    op.drop_column('cmf_form', 'roistat')
    op.drop_column('cmf_form', 'google_analytics')
    op.drop_column('cmf_form', 'failure_text')
    op.drop_column('cmf_form', 'custom_css')
    op.drop_index(op.f('ix_cmf_form_field_orderno'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_name'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_form_id'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_code'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_viewed_at'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_version'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_owner_id'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_modified_by_id'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_modified_at'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_locked_by_id'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_locked_at'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_deleted'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_created_at'), table_name='cmf_form_field')
    op.drop_index(op.f('ix_cmf_form_field_cmf_author_id'), table_name='cmf_form_field')
    op.drop_table('cmf_form_field')
    # ### end Alembic commands ###
