"""ldap

Revision ID: 6d14082c7ee2
Revises: ffac8603544f
Create Date: 2022-09-12 12:24:53.599826

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6d14082c7ee2'
down_revision = 'ffac8603544f'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_auth_plugin_data',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('cmf_locked_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_created_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_modified_at', sa.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('cmf_viewed_at', sa.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('cmf_deleted', sa.Boolean(), nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), nullable=True),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('system', sa.Boolean(), nullable=False),
    sa.Column('text', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('is_favorite', sa.Boolean(), nullable=True),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=True),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=True),
    sa.Column('tree_hidden', sa.Boolean(), nullable=True),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=True),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=True),
    sa.Column('perm_inherit', sa.Boolean(), nullable=True),
    sa.Column('perm_parent_owner_id', sa.String(length=64), nullable=True),
    sa.Column('perm_inherit_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_effective_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=True),
    sa.Column('login', sa.String(), nullable=False),
    sa.Column('groups', sa.TEXT(), nullable=False),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('phone', sa.String(), nullable=True),
    sa.Column('desc', sa.String(), nullable=True),
    sa.Column('cmf_author_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_owner_assistant_id', sa.String(length=64), nullable=True),
    sa.Column('parent_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_modified_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_locked_by_id', sa.String(length=64), nullable=True),
    sa.Column('cmf_import_id', sa.String(length=64), nullable=True),
    sa.Column('tree_parent_id', sa.String(length=64), nullable=True),
    sa.Column('perm_acl_id', sa.String(length=64), nullable=True),
    sa.Column('perm_parent_id', sa.String(length=64), nullable=True),
    sa.Column('auth_plugin_id', sa.String(length=64), nullable=True),
    sa.Column('person_id', sa.String(length=64), nullable=True),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['cmf_person.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_auth_plugin_data_auth_plugin_id'), 'cmf_auth_plugin_data', ['auth_plugin_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_author_id'), 'cmf_auth_plugin_data', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_created_at'), 'cmf_auth_plugin_data', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_deleted'), 'cmf_auth_plugin_data', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_import_id'), 'cmf_auth_plugin_data', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_locked_at'), 'cmf_auth_plugin_data', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_locked_by_id'), 'cmf_auth_plugin_data', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_modified_at'), 'cmf_auth_plugin_data', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_modified_by_id'), 'cmf_auth_plugin_data', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_owner_assistant_id'), 'cmf_auth_plugin_data', ['cmf_owner_assistant_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_owner_id'), 'cmf_auth_plugin_data', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_version'), 'cmf_auth_plugin_data', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_cmf_viewed_at'), 'cmf_auth_plugin_data', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_code'), 'cmf_auth_plugin_data', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_auth_plugin_data_ext_id'), 'cmf_auth_plugin_data', ['ext_id'], unique=True)
    op.create_index(op.f('ix_cmf_auth_plugin_data_orderno'), 'cmf_auth_plugin_data', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_parent_id'), 'cmf_auth_plugin_data', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_perm_acl_id'), 'cmf_auth_plugin_data', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_perm_parent_id'), 'cmf_auth_plugin_data', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_person_id'), 'cmf_auth_plugin_data', ['person_id'], unique=False)
    op.create_index(op.f('ix_cmf_auth_plugin_data_tree_parent_id'), 'cmf_auth_plugin_data', ['tree_parent_id'], unique=False)
    op.add_column('cmf_auth_ldap_plugin', sa.Column('sync_status', sa.String(length=32), nullable=True))
    op.add_column('cmf_global_var', sa.Column('auth_options_allow_base', sa.Boolean(), nullable=True))
    op.add_column('cmf_global_var', sa.Column('auth_options_admin_allow_base', sa.Boolean(), nullable=True))
    op.add_column('cmf_global_var', sa.Column('auth_options_allow_ldap', sa.Boolean(), nullable=True))
    op.add_column('cmf_global_var', sa.Column('auth_options_admin_allow_ldap', sa.Boolean(), nullable=True))
    op.add_column('cmf_global_var', sa.Column('auth_options_allow_oauth', sa.Boolean(), nullable=True))
    op.add_column('cmf_global_var', sa.Column('auth_options_admin_allow_oauth', sa.Boolean(), nullable=True))
    op.add_column('cmf_person', sa.Column('auth_options', sa.TEXT(), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('cmf_person', 'auth_options')
    op.drop_column('cmf_global_var', 'auth_options_admin_allow_oauth')
    op.drop_column('cmf_global_var', 'auth_options_allow_oauth')
    op.drop_column('cmf_global_var', 'auth_options_admin_allow_ldap')
    op.drop_column('cmf_global_var', 'auth_options_allow_ldap')
    op.drop_column('cmf_global_var', 'auth_options_admin_allow_base')
    op.drop_column('cmf_global_var', 'auth_options_allow_base')
    op.drop_column('cmf_auth_ldap_plugin', 'sync_status')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_tree_parent_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_person_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_perm_parent_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_perm_acl_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_parent_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_orderno'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_ext_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_code'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_viewed_at'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_version'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_owner_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_owner_assistant_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_modified_by_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_modified_at'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_locked_by_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_locked_at'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_import_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_deleted'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_created_at'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_cmf_author_id'), table_name='cmf_auth_plugin_data')
    op.drop_index(op.f('ix_cmf_auth_plugin_data_auth_plugin_id'), table_name='cmf_auth_plugin_data')
    op.drop_table('cmf_auth_plugin_data')
    # ### end Alembic commands ###
