20 lines
1.0 KiB
SQL
20 lines
1.0 KiB
SQL
-- Precondition receipts only. No executor capability is granted by this table.
|
|
CREATE TABLE IF NOT EXISTS vrf_production_tickets (
|
|
ticket_id uuid PRIMARY KEY,
|
|
plan_id uuid NOT NULL UNIQUE REFERENCES mcp_plans(id),
|
|
connection_id uuid NOT NULL REFERENCES mcp_connections(id),
|
|
server_id bigint NOT NULL REFERENCES servers(id),
|
|
owner_id text NOT NULL,
|
|
action_id text NOT NULL CHECK (action_id IN ('ros.vrf.create','ros.vrf.update','ros.vrf.delete')),
|
|
action_version integer NOT NULL CHECK (action_version > 0),
|
|
source_proof text NOT NULL CHECK (source_proof ~ '^[a-f0-9]{64}$'),
|
|
digest text NOT NULL CHECK (digest ~ '^[a-f0-9]{64}$'),
|
|
ciphertext text NOT NULL,
|
|
state text NOT NULL DEFAULT 'issued' CHECK (state IN ('issued','claimed')),
|
|
issued_at timestamptz NOT NULL,
|
|
expires_at timestamptz NOT NULL,
|
|
claimed_at timestamptz,
|
|
CHECK (expires_at > issued_at AND expires_at <= issued_at + interval '5 minutes'),
|
|
CHECK ((state='issued' AND claimed_at IS NULL) OR (state='claimed' AND claimed_at IS NOT NULL))
|
|
);
|