|
5 | 5 | Create Date: 2025-07-24 09:51:55.814649
|
6 | 6 |
|
7 | 7 | """
|
8 |
| -from alembic import op |
| 8 | + |
9 | 9 | import sqlalchemy as sa
|
| 10 | +from alembic import op |
10 | 11 | from sqlalchemy.dialects import mysql
|
11 | 12 |
|
12 | 13 | # revision identifiers, used by Alembic.
|
13 |
| -revision = '7793881905c5' |
14 |
| -down_revision = 'b3ed927671bd' |
| 14 | +revision = "7793881905c5" |
| 15 | +down_revision = "b3ed927671bd" |
15 | 16 | branch_labels = None
|
16 | 17 | depends_on = None
|
17 | 18 |
|
18 | 19 |
|
19 | 20 | def upgrade():
|
20 | 21 | # ### 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") |
30 | 56 |
|
31 | 57 | # ### end Alembic commands ###
|
32 | 58 |
|
33 | 59 |
|
34 | 60 | def downgrade():
|
35 | 61 | # ### 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") |
45 | 88 |
|
46 | 89 | # ### end Alembic commands ###
|
0 commit comments