|
| 1 | +"""Dynamic pipelines [af27025fe19c]. |
| 2 | +
|
| 3 | +Revision ID: af27025fe19c |
| 4 | +Revises: 0.91.0 |
| 5 | +Create Date: 2025-10-27 13:23:40.442485 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +import sqlalchemy as sa |
| 10 | +import sqlmodel |
| 11 | +from alembic import op |
| 12 | + |
| 13 | +# revision identifiers, used by Alembic. |
| 14 | +revision = "af27025fe19c" |
| 15 | +down_revision = "0.91.0" |
| 16 | +branch_labels = None |
| 17 | +depends_on = None |
| 18 | + |
| 19 | + |
| 20 | +def upgrade() -> None: |
| 21 | + """Upgrade database schema and/or data, creating a new revision.""" |
| 22 | + # ### commands auto generated by Alembic - please adjust! ### |
| 23 | + with op.batch_alter_table("pipeline_snapshot", schema=None) as batch_op: |
| 24 | + batch_op.add_column( |
| 25 | + sa.Column("is_dynamic", sa.Boolean(), nullable=False) |
| 26 | + ) |
| 27 | + |
| 28 | + with op.batch_alter_table("step_configuration", schema=None) as batch_op: |
| 29 | + # TODO: missing check constraint |
| 30 | + batch_op.add_column( |
| 31 | + sa.Column( |
| 32 | + "step_run_id", sqlmodel.sql.sqltypes.GUID(), nullable=True |
| 33 | + ) |
| 34 | + ) |
| 35 | + batch_op.alter_column( |
| 36 | + "snapshot_id", existing_type=sa.CHAR(length=32), nullable=True |
| 37 | + ) |
| 38 | + batch_op.drop_constraint( |
| 39 | + "unique_step_name_for_snapshot", type_="unique" |
| 40 | + ) |
| 41 | + batch_op.create_unique_constraint( |
| 42 | + "unique_step_name_for_snapshot", |
| 43 | + ["snapshot_id", "step_run_id", "name"], |
| 44 | + ) |
| 45 | + batch_op.create_foreign_key( |
| 46 | + "fk_step_configuration_step_run_id_step_run", |
| 47 | + "step_run", |
| 48 | + ["step_run_id"], |
| 49 | + ["id"], |
| 50 | + ondelete="CASCADE", |
| 51 | + ) |
| 52 | + |
| 53 | + # ### end Alembic commands ### |
| 54 | + |
| 55 | + |
| 56 | +def downgrade() -> None: |
| 57 | + """Downgrade database schema and/or data back to the previous revision.""" |
| 58 | + # ### commands auto generated by Alembic - please adjust! ### |
| 59 | + with op.batch_alter_table("step_configuration", schema=None) as batch_op: |
| 60 | + batch_op.drop_constraint( |
| 61 | + "fk_step_configuration_step_run_id_step_run", type_="foreignkey" |
| 62 | + ) |
| 63 | + batch_op.drop_constraint( |
| 64 | + "unique_step_name_for_snapshot", type_="unique" |
| 65 | + ) |
| 66 | + batch_op.create_unique_constraint( |
| 67 | + "unique_step_name_for_snapshot", ["snapshot_id", "name"] |
| 68 | + ) |
| 69 | + batch_op.alter_column( |
| 70 | + "snapshot_id", existing_type=sa.CHAR(length=32), nullable=False |
| 71 | + ) |
| 72 | + batch_op.drop_column("step_run_id") |
| 73 | + |
| 74 | + with op.batch_alter_table("pipeline_snapshot", schema=None) as batch_op: |
| 75 | + batch_op.drop_column("is_dynamic") |
| 76 | + |
| 77 | + # ### end Alembic commands ### |
0 commit comments