From 75a7042bb30e53be29d0420fd19f1fc44c9b2fa2 Mon Sep 17 00:00:00 2001 From: Hridesh MG Date: Thu, 24 Jul 2025 16:13:38 +0530 Subject: [PATCH] chore: add migration for last_passed_on --- migrations/versions/7793881905c5_.py | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 migrations/versions/7793881905c5_.py diff --git a/migrations/versions/7793881905c5_.py b/migrations/versions/7793881905c5_.py new file mode 100644 index 00000000..74ad7812 --- /dev/null +++ b/migrations/versions/7793881905c5_.py @@ -0,0 +1,46 @@ +"""split last_passed_on into two + +Revision ID: 7793881905c5 +Revises: b3ed927671bd +Create Date: 2025-07-24 09:51:55.814649 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = '7793881905c5' +down_revision = 'b3ed927671bd' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('regression_test', schema=None) as batch_op: + batch_op.add_column(sa.Column('last_passed_on_windows', sa.Integer(), nullable=True)) + batch_op.add_column(sa.Column('last_passed_on_linux', sa.Integer(), nullable=True)) + batch_op.drop_constraint('regression_test_ibfk_2', type_='foreignkey') + batch_op.drop_constraint('regression_test_ibfk_1', type_='foreignkey') + batch_op.create_foreign_key(None, 'test', ['last_passed_on_windows'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + batch_op.create_foreign_key(None, 'test', ['last_passed_on_linux'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + batch_op.create_foreign_key(None, 'sample', ['sample_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + batch_op.drop_column('last_passed_on') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('regression_test', schema=None) as batch_op: + batch_op.add_column(sa.Column('last_passed_on', mysql.INTEGER(), autoincrement=False, nullable=True)) + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('regression_test_ibfk_1', 'sample', ['sample_id'], ['id'], onupdate='CASCADE') + batch_op.create_foreign_key('regression_test_ibfk_2', 'test', ['last_passed_on'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + batch_op.drop_column('last_passed_on_linux') + batch_op.drop_column('last_passed_on_windows') + + # ### end Alembic commands ###