Skip to content

Commit 04c62ec

Browse files
hrideshmgcanihavesomecoffee
authored andcommitted
chore: format migration file
1 parent b4fb803 commit 04c62ec

File tree

1 file changed

+64
-21
lines changed

1 file changed

+64
-21
lines changed

migrations/versions/7793881905c5_.py

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,85 @@
55
Create Date: 2025-07-24 09:51:55.814649
66
77
"""
8-
from alembic import op
8+
99
import sqlalchemy as sa
10+
from alembic import op
1011
from sqlalchemy.dialects import mysql
1112

1213
# revision identifiers, used by Alembic.
13-
revision = '7793881905c5'
14-
down_revision = 'b3ed927671bd'
14+
revision = "7793881905c5"
15+
down_revision = "b3ed927671bd"
1516
branch_labels = None
1617
depends_on = None
1718

1819

1920
def upgrade():
2021
# ### 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')
22+
with op.batch_alter_table("regression_test", schema=None) as batch_op:
23+
batch_op.add_column(
24+
sa.Column("last_passed_on_windows", sa.Integer(), nullable=True)
25+
)
26+
batch_op.add_column(
27+
sa.Column("last_passed_on_linux", sa.Integer(), nullable=True)
28+
)
29+
batch_op.drop_constraint("regression_test_ibfk_2", type_="foreignkey")
30+
batch_op.drop_constraint("regression_test_ibfk_1", type_="foreignkey")
31+
batch_op.create_foreign_key(
32+
None,
33+
"test",
34+
["last_passed_on_windows"],
35+
["id"],
36+
onupdate="CASCADE",
37+
ondelete="SET NULL",
38+
)
39+
batch_op.create_foreign_key(
40+
None,
41+
"test",
42+
["last_passed_on_linux"],
43+
["id"],
44+
onupdate="CASCADE",
45+
ondelete="SET NULL",
46+
)
47+
batch_op.create_foreign_key(
48+
None,
49+
"sample",
50+
["sample_id"],
51+
["id"],
52+
onupdate="CASCADE",
53+
ondelete="CASCADE",
54+
)
55+
batch_op.drop_column("last_passed_on")
3056

3157
# ### end Alembic commands ###
3258

3359

3460
def downgrade():
3561
# ### 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')
62+
with op.batch_alter_table("regression_test", schema=None) as batch_op:
63+
batch_op.add_column(
64+
sa.Column(
65+
"last_passed_on", mysql.INTEGER(), autoincrement=False, nullable=True
66+
)
67+
)
68+
batch_op.drop_constraint(None, type_="foreignkey")
69+
batch_op.drop_constraint(None, type_="foreignkey")
70+
batch_op.drop_constraint(None, type_="foreignkey")
71+
batch_op.create_foreign_key(
72+
"regression_test_ibfk_1",
73+
"sample",
74+
["sample_id"],
75+
["id"],
76+
onupdate="CASCADE",
77+
)
78+
batch_op.create_foreign_key(
79+
"regression_test_ibfk_2",
80+
"test",
81+
["last_passed_on"],
82+
["id"],
83+
onupdate="CASCADE",
84+
ondelete="SET NULL",
85+
)
86+
batch_op.drop_column("last_passed_on_linux")
87+
batch_op.drop_column("last_passed_on_windows")
4588

4689
# ### end Alembic commands ###

0 commit comments

Comments
 (0)