42 lines
2.5 KiB
Python
42 lines
2.5 KiB
Python
# #region Alembic.ScenarioLiveExecutionBinding [C:3] [TYPE Module] [SEMANTICS alembic,migration,scenario,execution,live-binding]
|
|
# @ingroup Alembic
|
|
# @BRIEF Add nullable immutable live-execution binding identity fields to durable scenario runs.
|
|
# @RELATION DEPENDS_ON -> [Models.ScenarioExecution.Run]
|
|
# @INVARIANT Existing runs remain valid with no binding and therefore fail closed as unavailable live I/O.
|
|
# @RATIONALE The new fields are nullable and additive so historical runs preserve their original lifecycle evidence.
|
|
# @REJECTED Backfilling binding authority from environment_id was rejected — an environment label is not a pinned RLS/principal/model capability.
|
|
"""add nullable ScenarioRun live execution binding identity snapshot (044)"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision: str = "c1d2e3f4a5b6"
|
|
down_revision: str | Sequence[str] | None = "b9c0d1e2f3a4"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
# #region Alembic.ScenarioLiveExecutionBinding.Upgrade [C:4] [TYPE Function] [SEMANTICS alembic,migration,scenario,live-binding,additive]
|
|
# @BRIEF Add nullable persisted live-binding identity fields without deriving legacy authority.
|
|
# @POST Existing scenario runs retain valid null binding fields; a lookup index exists for binding_ref.
|
|
# @SIDE_EFFECT Schema mutation: two nullable columns and one index on scenario_runs.
|
|
def upgrade() -> None:
|
|
op.add_column("scenario_runs", sa.Column("live_execution_binding_ref", sa.String(128), nullable=True))
|
|
op.add_column("scenario_runs", sa.Column("live_execution_binding_snapshot", sa.JSON(), nullable=True))
|
|
op.create_index("ix_scenario_runs_live_execution_binding_ref", "scenario_runs", ["live_execution_binding_ref"])
|
|
# #endregion Alembic.ScenarioLiveExecutionBinding.Upgrade
|
|
|
|
|
|
# #region Alembic.ScenarioLiveExecutionBinding.Downgrade [C:3] [TYPE Function] [SEMANTICS alembic,migration,scenario,live-binding,rollback]
|
|
# @BRIEF Remove only the additive live-binding fields in reverse dependency order.
|
|
# @SIDE_EFFECT Schema mutation: binding-ref index and nullable columns are removed.
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_scenario_runs_live_execution_binding_ref", table_name="scenario_runs")
|
|
op.drop_column("scenario_runs", "live_execution_binding_snapshot")
|
|
op.drop_column("scenario_runs", "live_execution_binding_ref")
|
|
# #endregion Alembic.ScenarioLiveExecutionBinding.Downgrade
|
|
# #endregion Alembic.ScenarioLiveExecutionBinding
|