"""

Revision ID: e25840fc4ceb
Revises: 693e866c4cd0
Create Date: 2023-02-28 15:35:21.392831

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'e25840fc4ceb'
down_revision = '693e866c4cd0'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_html_scheme',
    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(length=256), 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('import_original', sa.Boolean(), nullable=True),
    sa.Column('import_raw_json', 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('header_background_color', sa.String(length=32), nullable=True),
    sa.Column('header_text_color', sa.String(length=32), nullable=True),
    sa.Column('content_background_color', sa.String(length=32), nullable=True),
    sa.Column('content_text_color', sa.String(length=32), nullable=True),
    sa.Column('footer_background_color', sa.String(length=32), nullable=True),
    sa.Column('footer_text_color', sa.String(length=32), nullable=True),
    sa.Column('sidebar_background_color', sa.String(length=32), nullable=True),
    sa.Column('sidebar_text_color', sa.String(length=32), nullable=True),
    sa.Column('footer_text', sa.TEXT(), nullable=True),
    sa.Column('custom_js', sa.TEXT(), nullable=True),
    sa.Column('custom_css', sa.TEXT(), 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('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('root_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.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], ),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_html_scheme_cmf_author_id'), 'cmf_html_scheme', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_created_at'), 'cmf_html_scheme', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_deleted'), 'cmf_html_scheme', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_import_id'), 'cmf_html_scheme', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_locked_at'), 'cmf_html_scheme', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_locked_by_id'), 'cmf_html_scheme', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_modified_at'), 'cmf_html_scheme', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_modified_by_id'), 'cmf_html_scheme', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_owner_id'), 'cmf_html_scheme', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_version'), 'cmf_html_scheme', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_cmf_viewed_at'), 'cmf_html_scheme', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_code'), 'cmf_html_scheme', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_html_scheme_name'), 'cmf_html_scheme', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_orderno'), 'cmf_html_scheme', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_parent_id'), 'cmf_html_scheme', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_perm_acl_id'), 'cmf_html_scheme', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_perm_parent_id'), 'cmf_html_scheme', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_root_parent_id'), 'cmf_html_scheme', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_html_scheme_tree_parent_id'), 'cmf_html_scheme', ['tree_parent_id'], unique=False)
    op.add_column('cmf_document', sa.Column('html_scheme_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_document', sa.Column('public_html_scheme_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_document_html_scheme_id'), 'cmf_document', ['html_scheme_id'], unique=False)
    op.create_index(op.f('ix_cmf_document_public_html_scheme_id'), 'cmf_document', ['public_html_scheme_id'], unique=False)
    op.create_foreign_key(None, 'cmf_document', 'cmf_html_scheme', ['html_scheme_id'], ['id'])
    op.create_foreign_key(None, 'cmf_document', 'cmf_html_scheme', ['public_html_scheme_id'], ['id'])
    op.add_column('cmf_project', sa.Column('document_header_text', sa.String(), nullable=True))
    op.add_column('cmf_project', sa.Column('document_footer_text', sa.String(), nullable=True))
    op.add_column('cmf_project', sa.Column('html_scheme_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_project', sa.Column('public_html_scheme_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_project_html_scheme_id'), 'cmf_project', ['html_scheme_id'], unique=False)
    op.create_index(op.f('ix_cmf_project_public_html_scheme_id'), 'cmf_project', ['public_html_scheme_id'], unique=False)
    op.create_foreign_key(None, 'cmf_project', 'cmf_html_scheme', ['html_scheme_id'], ['id'])
    op.create_foreign_key(None, 'cmf_project', 'cmf_html_scheme', ['public_html_scheme_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_project', type_='foreignkey')
    op.drop_constraint(None, 'cmf_project', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_project_public_html_scheme_id'), table_name='cmf_project')
    op.drop_index(op.f('ix_cmf_project_html_scheme_id'), table_name='cmf_project')
    op.drop_column('cmf_project', 'public_html_scheme_id')
    op.drop_column('cmf_project', 'html_scheme_id')
    op.drop_column('cmf_project', 'document_footer_text')
    op.drop_column('cmf_project', 'document_header_text')
    op.drop_constraint(None, 'cmf_document', type_='foreignkey')
    op.drop_constraint(None, 'cmf_document', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_document_public_html_scheme_id'), table_name='cmf_document')
    op.drop_index(op.f('ix_cmf_document_html_scheme_id'), table_name='cmf_document')
    op.drop_column('cmf_document', 'public_html_scheme_id')
    op.drop_column('cmf_document', 'html_scheme_id')
    op.drop_index(op.f('ix_cmf_html_scheme_tree_parent_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_root_parent_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_perm_parent_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_perm_acl_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_parent_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_orderno'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_name'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_code'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_viewed_at'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_version'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_owner_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_modified_by_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_modified_at'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_locked_by_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_locked_at'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_import_id'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_deleted'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_created_at'), table_name='cmf_html_scheme')
    op.drop_index(op.f('ix_cmf_html_scheme_cmf_author_id'), table_name='cmf_html_scheme')
    op.drop_table('cmf_html_scheme')
    # ### end Alembic commands ###
