Skip to content

Commit 306a8e5

Browse files
hrideshmgcanihavesomecoffee
authored andcommitted
chore: add migration for last_passed_on
1 parent 71af9fb commit 306a8e5

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""split last_passed_on into two
2+
3+
Revision ID: 7793881905c5
4+
Revises: b3ed927671bd
5+
Create Date: 2025-07-24 09:51:55.814649
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import mysql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '7793881905c5'
14+
down_revision = 'b3ed927671bd'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
with op.batch_alter_table('regression_test', schema=None) as batch_op:
22+
batch_op.add_column(sa.Column('last_passed_on_windows', sa.Integer(), nullable=True))
23+
batch_op.add_column(sa.Column('last_passed_on_linux', sa.Integer(), nullable=True))
24+
batch_op.drop_constraint('regression_test_ibfk_2', type_='foreignkey')
25+
batch_op.drop_constraint('regression_test_ibfk_1', type_='foreignkey')
26+
batch_op.create_foreign_key(None, 'test', ['last_passed_on_windows'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
27+
batch_op.create_foreign_key(None, 'test', ['last_passed_on_linux'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
28+
batch_op.create_foreign_key(None, 'sample', ['sample_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
29+
batch_op.drop_column('last_passed_on')
30+
31+
# ### end Alembic commands ###
32+
33+
34+
def downgrade():
35+
# ### commands auto generated by Alembic - please adjust! ###
36+
with op.batch_alter_table('regression_test', schema=None) as batch_op:
37+
batch_op.add_column(sa.Column('last_passed_on', mysql.INTEGER(), autoincrement=False, nullable=True))
38+
batch_op.drop_constraint(None, type_='foreignkey')
39+
batch_op.drop_constraint(None, type_='foreignkey')
40+
batch_op.drop_constraint(None, type_='foreignkey')
41+
batch_op.create_foreign_key('regression_test_ibfk_1', 'sample', ['sample_id'], ['id'], onupdate='CASCADE')
42+
batch_op.create_foreign_key('regression_test_ibfk_2', 'test', ['last_passed_on'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
43+
batch_op.drop_column('last_passed_on_linux')
44+
batch_op.drop_column('last_passed_on_windows')
45+
46+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)