"""evatest

Revision ID: 301e6ae52d16
Revises: 1f5c20582665
Create Date: 2025-02-13 10:30:00.355780

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

# revision identifiers, used by Alembic.
revision = '301e6ae52d16'
down_revision = '1f5c20582665'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_test_params_row',
    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=False),
    sa.Column('import_raw_json', sa.TEXT(), nullable=True),
    sa.Column('ext_id', sa.String(), nullable=True),
    sa.Column('cmf_archived', sa.Boolean(), nullable=False),
    sa.Column('is_favorite', sa.Boolean(), nullable=False),
    sa.Column('has_tree_nodes', sa.Boolean(), nullable=False),
    sa.Column('tree_node_is_branch', sa.Boolean(), nullable=False),
    sa.Column('tree_hidden', sa.Boolean(), nullable=False),
    sa.Column('sl_owner_lock', sa.Boolean(), nullable=False),
    sa.Column('orderno', sa.Integer(), nullable=True),
    sa.Column('perm_public', sa.Boolean(), nullable=False),
    sa.Column('perm_has_acl', sa.Boolean(), nullable=False),
    sa.Column('perm_inherit', sa.Boolean(), nullable=False),
    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_security_level_allowed_ids_cache', sa.TEXT(), nullable=True),
    sa.Column('perm_encrypt', sa.Boolean(), nullable=False),
    sa.Column('perm_encrypt_help', sa.String(length=256), 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('project_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.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_test_params_row_cmf_author_id'), 'cmf_test_params_row', ['cmf_author_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_created_at'), 'cmf_test_params_row', ['cmf_created_at'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_deleted'), 'cmf_test_params_row', ['cmf_deleted'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_import_id'), 'cmf_test_params_row', ['cmf_import_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_locked_at'), 'cmf_test_params_row', ['cmf_locked_at'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_locked_by_id'), 'cmf_test_params_row', ['cmf_locked_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_modified_at'), 'cmf_test_params_row', ['cmf_modified_at'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_modified_by_id'), 'cmf_test_params_row', ['cmf_modified_by_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_owner_id'), 'cmf_test_params_row', ['cmf_owner_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_version'), 'cmf_test_params_row', ['cmf_version'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_cmf_viewed_at'), 'cmf_test_params_row', ['cmf_viewed_at'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_code'), 'cmf_test_params_row', ['code'], unique=True)
    op.create_index(op.f('ix_cmf_test_params_row_name'), 'cmf_test_params_row', ['name'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_orderno'), 'cmf_test_params_row', ['orderno'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_parent_id'), 'cmf_test_params_row', ['parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_perm_acl_id'), 'cmf_test_params_row', ['perm_acl_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_perm_parent_id'), 'cmf_test_params_row', ['perm_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_project_id'), 'cmf_test_params_row', ['project_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_root_parent_id'), 'cmf_test_params_row', ['root_parent_id'], unique=False)
    op.create_index(op.f('ix_cmf_test_params_row_tree_parent_id'), 'cmf_test_params_row', ['tree_parent_id'], unique=False)
    op.drop_index('ix_cmf_testcase_params_row_cmf_author_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_created_at', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_deleted', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_import_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_locked_at', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_locked_by_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_modified_at', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_modified_by_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_owner_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_version', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_cmf_viewed_at', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_code', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_name', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_orderno', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_parent_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_perm_acl_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_perm_parent_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_project_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_root_parent_id', table_name='cmf_testcase_params_row')
    op.drop_index('ix_cmf_testcase_params_row_tree_parent_id', table_name='cmf_testcase_params_row')
    op.execute("TRUNCATE TABLE cmf_testcase_run")
    op.drop_constraint('cmf_test_param_row_value_parent_id_fkey', 'cmf_test_param_row_value', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_test_param_row_value', 'cmf_test_params_row', ['parent_id'], ['id'])
    op.drop_constraint('cmf_testcase_run_params_row_id_fkey', 'cmf_testcase_run', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_testcase_run', 'cmf_test_params_row', ['params_row_id'], ['id'])
    op.drop_table('cmf_testcase_params_row')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_testcase_run', type_='foreignkey')
    op.create_foreign_key('cmf_testcase_run_params_row_id_fkey', 'cmf_testcase_run', 'cmf_testcase_params_row', ['params_row_id'], ['id'])
    op.drop_constraint(None, 'cmf_test_param_row_value', type_='foreignkey')
    op.create_foreign_key('cmf_test_param_row_value_parent_id_fkey', 'cmf_test_param_row_value', 'cmf_testcase_params_row', ['parent_id'], ['id'])
    op.create_table('cmf_testcase_params_row',
    sa.Column('id', sa.VARCHAR(length=64), autoincrement=False, nullable=False),
    sa.Column('cmf_locked_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('cmf_created_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
    sa.Column('cmf_modified_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
    sa.Column('cmf_viewed_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('cmf_deleted', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('cmf_version', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('code', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('system', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('text', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('import_original', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('import_raw_json', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('ext_id', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('cmf_archived', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('is_favorite', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('has_tree_nodes', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('tree_node_is_branch', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('tree_hidden', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('sl_owner_lock', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('orderno', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('perm_public', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('perm_has_acl', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('perm_inherit', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('perm_parent_owner_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('perm_inherit_acl_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('perm_effective_acl_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('perm_security_level_allowed_ids_cache', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('perm_encrypt', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('perm_encrypt_help', sa.VARCHAR(length=256), autoincrement=False, nullable=True),
    sa.Column('cmf_author_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('cmf_owner_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('cmf_modified_by_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('cmf_locked_by_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('cmf_import_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('tree_parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('root_parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('project_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('perm_acl_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.Column('perm_parent_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['cmf_import_id'], ['cmf_import.id'], name='cmf_testcase_params_row_cmf_import_id_fkey'),
    sa.ForeignKeyConstraint(['perm_acl_id'], ['cmf_access_list.id'], name='cmf_testcase_params_row_perm_acl_id_fkey'),
    sa.ForeignKeyConstraint(['project_id'], ['cmf_project.id'], name='cmf_testcase_params_row_project_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='cmf_testcase_params_row_pkey')
    )
    op.create_index('ix_cmf_testcase_params_row_tree_parent_id', 'cmf_testcase_params_row', ['tree_parent_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_root_parent_id', 'cmf_testcase_params_row', ['root_parent_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_project_id', 'cmf_testcase_params_row', ['project_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_perm_parent_id', 'cmf_testcase_params_row', ['perm_parent_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_perm_acl_id', 'cmf_testcase_params_row', ['perm_acl_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_parent_id', 'cmf_testcase_params_row', ['parent_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_orderno', 'cmf_testcase_params_row', ['orderno'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_name', 'cmf_testcase_params_row', ['name'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_code', 'cmf_testcase_params_row', ['code'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_viewed_at', 'cmf_testcase_params_row', ['cmf_viewed_at'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_version', 'cmf_testcase_params_row', ['cmf_version'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_owner_id', 'cmf_testcase_params_row', ['cmf_owner_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_modified_by_id', 'cmf_testcase_params_row', ['cmf_modified_by_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_modified_at', 'cmf_testcase_params_row', ['cmf_modified_at'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_locked_by_id', 'cmf_testcase_params_row', ['cmf_locked_by_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_locked_at', 'cmf_testcase_params_row', ['cmf_locked_at'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_import_id', 'cmf_testcase_params_row', ['cmf_import_id'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_deleted', 'cmf_testcase_params_row', ['cmf_deleted'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_created_at', 'cmf_testcase_params_row', ['cmf_created_at'], unique=False)
    op.create_index('ix_cmf_testcase_params_row_cmf_author_id', 'cmf_testcase_params_row', ['cmf_author_id'], unique=False)
    op.drop_index(op.f('ix_cmf_test_params_row_tree_parent_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_root_parent_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_project_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_perm_parent_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_perm_acl_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_parent_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_orderno'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_name'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_code'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_viewed_at'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_version'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_owner_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_modified_by_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_modified_at'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_locked_by_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_locked_at'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_import_id'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_deleted'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_created_at'), table_name='cmf_test_params_row')
    op.drop_index(op.f('ix_cmf_test_params_row_cmf_author_id'), table_name='cmf_test_params_row')
    op.drop_table('cmf_test_params_row')
    # ### end Alembic commands ###
