20260723_130_bound_plan_lifecycle.py 736 B

123456789101112131415161718192021222324252627
  1. """Pin the Task 4 physical-plan lifecycle to compiled-only creation."""
  2. from alembic import op
  3. revision = "20260723_130"
  4. down_revision = "20260723_120"
  5. branch_labels = None
  6. depends_on = None
  7. def upgrade() -> None:
  8. op.execute(
  9. """
  10. ALTER TABLE public.rule_execution_plans
  11. DROP CONSTRAINT rule_execution_plans_status_check;
  12. ALTER TABLE public.rule_execution_plans
  13. ADD CONSTRAINT rule_execution_plans_status_check
  14. CHECK (status IN ('compiled','published','revoked'));
  15. """
  16. )
  17. def downgrade() -> None:
  18. raise RuntimeError(
  19. "bound plan status migration is forward-only and cannot downgrade "
  20. "without rewriting persisted compiled plans"
  21. )