"""zadarma

Revision ID: 022065a4aa21
Revises: e905cacd4720
Create Date: 2021-08-18 10:58:47.582921

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '022065a4aa21'
down_revision = 'e905cacd4720'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_zadarma',
    sa.Column('cache_last_comments', sa.TEXT(), nullable=False),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_assistant_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('parent_id', sa.String(length=64), nullable=True),
    sa.Column('secret_id', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['secret_id'], ['cmf_secret.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_zadarma_cmf_author_id'), 'cmf_zadarma', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_created_at'), 'cmf_zadarma', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_deleted'), 'cmf_zadarma', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_import_id'), 'cmf_zadarma', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_locked_at'), 'cmf_zadarma', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_locked_by_id'), 'cmf_zadarma', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_modified_at'), 'cmf_zadarma', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_modified_by_id'), 'cmf_zadarma', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_owner_assistant_id'), 'cmf_zadarma', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_owner_id'), 'cmf_zadarma', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_version'), 'cmf_zadarma', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_cmf_viewed_at'), 'cmf_zadarma', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_code'), 'cmf_zadarma', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_zadarma_name'), 'cmf_zadarma', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_parent_id'), 'cmf_zadarma', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_zadarma_secret_id'), 'cmf_zadarma', ['secret_id'], unique=False)

    op.add_column('cmf_secret', sa.Column('ext_key', sa.String(length=64), nullable=True))
    op.add_column('cmf_secret', sa.Column('ext_secret', sa.String(length=64), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('cmf_secret', 'ext_secret')
    op.drop_column('cmf_secret', 'ext_key')

    op.drop_index(op.f('ix_cmf_zadarma_secret_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_parent_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_name'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_code'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_viewed_at'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_version'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_owner_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_owner_assistant_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_modified_by_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_modified_at'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_locked_by_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_locked_at'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_import_id'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_deleted'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_created_at'), table_name='cmf_zadarma')
    op.drop_index(op.f('ix_cmf_zadarma_cmf_author_id'), table_name='cmf_zadarma')
    op.drop_table('cmf_zadarma')
    # ### end Alembic commands ###
