26 lines
1.1 KiB
SQL
26 lines
1.1 KiB
SQL
-- +goose Up
|
|
-- Replay follows the generic record's 24-hour retention. Expired records are
|
|
-- removed by bounded opportunistic purges, so physical deletion may happen
|
|
-- later; this foreign key removes the snapshot with its record. The snapshot
|
|
-- is separate from the live organization so later profile edits cannot change
|
|
-- a replay. It contains bounded profile and owner-membership data, never a
|
|
-- request key.
|
|
CREATE TABLE organization_creation_results (
|
|
scope_hash bytea NOT NULL,
|
|
snapshot jsonb NOT NULL,
|
|
CONSTRAINT organization_creation_results_pkey PRIMARY KEY (scope_hash),
|
|
CONSTRAINT organization_creation_results_idempotency_fkey FOREIGN KEY (
|
|
scope_hash
|
|
) REFERENCES idempotency_records (scope_hash) ON DELETE CASCADE,
|
|
CONSTRAINT organization_creation_results_scope_hash_sha256 CHECK (
|
|
octet_length(scope_hash) = 32
|
|
),
|
|
CONSTRAINT organization_creation_results_snapshot_bounded CHECK (
|
|
jsonb_typeof(snapshot) = 'object'
|
|
AND octet_length(snapshot::text) <= 65536
|
|
)
|
|
);
|
|
|
|
-- +goose Down
|
|
DROP TABLE organization_creation_results;
|