25 lines
1.0 KiB
PL/PgSQL
25 lines
1.0 KiB
PL/PgSQL
BEGIN;
|
|
CREATE TABLE IF NOT EXISTS mcp_scoped_recovery_intents (
|
|
source_operation_id uuid NOT NULL REFERENCES mcp_operations(id),
|
|
source_step_index integer NOT NULL CHECK(source_step_index>=0),
|
|
source_receipt_id uuid NOT NULL,
|
|
source_configuration_proof text NOT NULL,
|
|
recovery_receipt_id uuid NOT NULL UNIQUE,
|
|
recovery_operation_id uuid REFERENCES mcp_operations(id),
|
|
mode text NOT NULL CHECK(mode IN ('manual','reserved')),
|
|
authority_profile_id uuid REFERENCES mcp_routing_profiles(id),
|
|
authority_profile_version integer,
|
|
intent_sealed text NOT NULL,
|
|
intent_proof text NOT NULL,
|
|
state text NOT NULL CHECK(state IN ('intent','verified','unknown')),
|
|
deadline timestamptz NOT NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
finished_at timestamptz,
|
|
verified_sealed text,
|
|
verified_proof text,
|
|
PRIMARY KEY(source_operation_id,source_step_index),
|
|
CHECK(mode='manual' OR authority_profile_id IS NOT NULL AND authority_profile_version IS NOT NULL),
|
|
CHECK((state='verified')=(verified_sealed IS NOT NULL AND verified_proof IS NOT NULL))
|
|
);
|
|
COMMIT;
|