"""evatest

Revision ID: a5d7d0c2ce1c
Revises: b92add5e2ed7
Create Date: 2025-02-12 11:07:18.145649

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'a5d7d0c2ce1c'
down_revision = 'b92add5e2ed7'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_cmf_testcase_param_cache_testcase_id', table_name='cmf_testcase_param')
    op.drop_constraint('cmf_testcase_param_cache_testcase_id_fkey', 'cmf_testcase_param', type_='foreignkey')
    op.drop_column('cmf_testcase_param', 'cache_testcase_id')
    op.add_column('cmf_testcase_run', sa.Column('cache_estimate_time', sa.Integer(), nullable=True))
    op.add_column('cmf_testcase_run', sa.Column('cur_history_id', sa.String(length=64), nullable=True))
    op.add_column('cmf_testcase_run', sa.Column('release_id', sa.String(length=64), nullable=True))
    op.drop_index('ix_cmf_testcase_run_cur_testcase_run_id', table_name='cmf_testcase_run')
    op.create_index(op.f('ix_cmf_testcase_run_cur_history_id'), 'cmf_testcase_run', ['cur_history_id'], unique=False)
    op.create_index(op.f('ix_cmf_testcase_run_release_id'), 'cmf_testcase_run', ['release_id'], unique=False)
    op.drop_constraint('cmf_testcase_run_cur_testcase_run_id_fkey', 'cmf_testcase_run', type_='foreignkey')
    op.create_foreign_key(None, 'cmf_testcase_run', 'cmf_list', ['release_id'], ['id'])
    op.create_foreign_key(None, 'cmf_testcase_run', 'cmf_testcase_run_history', ['cur_history_id'], ['id'])
    op.drop_column('cmf_testcase_run', 'cur_testcase_run_id')
    op.drop_column('cmf_testcase_run', 'estimate_time')
    op.add_column('cmf_testcase_run_history', sa.Column('cache_estimate_time', sa.Integer(), nullable=True))
    op.drop_index('ix_cmf_testcase_run_history_params_row_id', table_name='cmf_testcase_run_history')
    op.drop_index('ix_cmf_testcase_run_history_release_id', table_name='cmf_testcase_run_history')
    op.drop_constraint('cmf_testcase_run_history_release_id_fkey', 'cmf_testcase_run_history', type_='foreignkey')
    op.drop_constraint('cmf_testcase_run_history_params_row_id_fkey', 'cmf_testcase_run_history', type_='foreignkey')
    op.drop_column('cmf_testcase_run_history', 'params_row_id')
    op.drop_column('cmf_testcase_run_history', 'estimate_time')
    op.drop_column('cmf_testcase_run_history', 'release_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_testcase_run_history', sa.Column('release_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.add_column('cmf_testcase_run_history', sa.Column('estimate_time', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('cmf_testcase_run_history', sa.Column('params_row_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.create_foreign_key('cmf_testcase_run_history_params_row_id_fkey', 'cmf_testcase_run_history', 'cmf_testcase_params_row', ['params_row_id'], ['id'])
    op.create_foreign_key('cmf_testcase_run_history_release_id_fkey', 'cmf_testcase_run_history', 'cmf_list', ['release_id'], ['id'])
    op.create_index('ix_cmf_testcase_run_history_release_id', 'cmf_testcase_run_history', ['release_id'], unique=False)
    op.create_index('ix_cmf_testcase_run_history_params_row_id', 'cmf_testcase_run_history', ['params_row_id'], unique=False)
    op.drop_column('cmf_testcase_run_history', 'cache_estimate_time')
    op.add_column('cmf_testcase_run', sa.Column('estimate_time', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('cmf_testcase_run', sa.Column('cur_testcase_run_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'cmf_testcase_run', type_='foreignkey')
    op.drop_constraint(None, 'cmf_testcase_run', type_='foreignkey')
    op.create_foreign_key('cmf_testcase_run_cur_testcase_run_id_fkey', 'cmf_testcase_run', 'cmf_testcase_run_history', ['cur_testcase_run_id'], ['id'])
    op.drop_index(op.f('ix_cmf_testcase_run_release_id'), table_name='cmf_testcase_run')
    op.drop_index(op.f('ix_cmf_testcase_run_cur_history_id'), table_name='cmf_testcase_run')
    op.create_index('ix_cmf_testcase_run_cur_testcase_run_id', 'cmf_testcase_run', ['cur_testcase_run_id'], unique=False)
    op.drop_column('cmf_testcase_run', 'release_id')
    op.drop_column('cmf_testcase_run', 'cur_history_id')
    op.drop_column('cmf_testcase_run', 'cache_estimate_time')
    op.add_column('cmf_testcase_param', sa.Column('cache_testcase_id', sa.VARCHAR(length=64), autoincrement=False, nullable=False))
    op.create_foreign_key('cmf_testcase_param_cache_testcase_id_fkey', 'cmf_testcase_param', 'cmf_testcase', ['cache_testcase_id'], ['id'])
    op.create_index('ix_cmf_testcase_param_cache_testcase_id', 'cmf_testcase_param', ['cache_testcase_id'], unique=False)
    # ### end Alembic commands ###
