| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- """Bind recoverable DataFlow creates to a canonical server-owned intent."""
- from alembic import op
- revision = "20260724_230"
- down_revision = "20260724_220"
- branch_labels = None
- depends_on = None
- def upgrade() -> None:
- op.execute(
- """
- ALTER TABLE public.dataflow_draft_reservations
- ADD COLUMN create_request JSONB,
- ADD COLUMN create_intent JSONB,
- ADD COLUMN request_digest CHAR(64);
- ALTER TABLE public.dataflow_draft_reservations
- ADD CONSTRAINT ck_dataflow_create_intent_complete
- CHECK (
- (
- create_request IS NULL
- AND create_intent IS NULL
- AND request_digest IS NULL
- )
- OR (
- create_request IS NOT NULL
- AND create_intent IS NOT NULL
- AND request_digest ~ '^[0-9a-f]{64}$'
- )
- );
- CREATE INDEX idx_dataflow_create_reconciliation
- ON public.dataflow_draft_reservations(
- state, lease_expires_at, updated_at
- )
- WHERE request_digest IS NOT NULL
- AND create_intent IS NOT NULL;
- """
- )
- def downgrade() -> None:
- raise RuntimeError(
- "DataFlow create intents are forward-only and cannot downgrade"
- )
|