net-kingdom/identity-provisioner/migrations/group_journal_postgres_v1.sql
tegwick 70f408ca23
Some checks failed
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Identity provider journey acceptance / provider (push) Failing after 13s
Build and Publish identity-provisioner / build-and-push (push) Successful in 26s
feat(identity): add PostgreSQL provenance and verify sealed SOPS custody
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a1468b-63fa-7710-85dc-8f2e16b3ebfa
2026-10-17 01:36:38 +02:00

23 lines
1.3 KiB
SQL

-- Run only by the admitted migration role in its existing owner schema.
-- Does not create a database/schema/credential, admit an epoch or clear quarantine.
CREATE TABLE identity_provisioner.group_journal_meta (
singleton boolean PRIMARY KEY CHECK (singleton = true),
epoch uuid NOT NULL,
directory text NOT NULL CHECK (octet_length(directory) BETWEEN 1 AND 1024),
head bigint NOT NULL CHECK (head >= 0),
head_digest text NOT NULL CHECK (head_digest ~ '^[0-9a-f]{64}$'),
quarantined boolean NOT NULL DEFAULT true
);
CREATE TABLE identity_provisioner.group_receipts (
context_digest text NOT NULL CHECK (context_digest ~ '^[0-9a-f]{64}$'),
context_json text NOT NULL CHECK (octet_length(context_json) <= 16384),
key text NOT NULL CHECK (char_length(key) BETWEEN 1 AND 256),
binding text NOT NULL CHECK (binding ~ '^[0-9a-f]{64}$'),
version bigint NOT NULL CHECK (version >= 1),
state text NOT NULL CHECK (state IN ('pending','ensured','revoking','revoked','uncertain','refused')),
active boolean UNIQUE CHECK (active IS NULL OR active = true),
body text NOT NULL CHECK (octet_length(body) <= 1048576),
PRIMARY KEY (context_digest, key)
);
-- Epoch insertion, initial continuity checkpoint and admission are separate
-- owner actions; this migration leaves all operations refused without them.