| 123456789101112131415161718192021222324252627282930313233343536 |
- """Add single-use actor-bound DataFlow draft reservations."""
- from alembic import op
- revision = "20260723_210"
- down_revision = "20260723_200"
- branch_labels = None
- depends_on = None
- def upgrade() -> None:
- op.execute(
- """
- CREATE TABLE public.dataflow_draft_reservations (
- id UUID PRIMARY KEY,
- dataflow_uid UUID NOT NULL UNIQUE,
- actor_uid UUID NOT NULL
- REFERENCES public.users(id) ON DELETE RESTRICT,
- nonce_hash CHAR(64) NOT NULL UNIQUE,
- expires_at TIMESTAMPTZ NOT NULL,
- consumed_at TIMESTAMPTZ,
- created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CHECK (expires_at > created_at)
- );
- CREATE INDEX idx_dataflow_draft_reservation_actor
- ON public.dataflow_draft_reservations(
- actor_uid, expires_at, consumed_at
- );
- """
- )
- def downgrade() -> None:
- raise RuntimeError(
- "DataFlow draft reservations are forward-only and cannot downgrade"
- )
|