Bind credential pins to immutable grants

This commit is contained in:
ms2k 2026-07-17 03:38:10 +09:00
commit d12543d730

View file

@ -24,13 +24,24 @@ CREATE TABLE execution_grants (
CONSTRAINT execution_grants_credential_check CHECK (
(credential_id IS NULL) = (credential_version_id IS NULL)
),
CONSTRAINT execution_grants_id_status_unique UNIQUE (grant_id, status)
CONSTRAINT execution_grants_authority_tuple_unique UNIQUE (
grant_id,
status,
credential_id,
credential_version_id
)
);
ALTER TABLE execution_grant_credential_pins
ADD CONSTRAINT execution_grant_pins_authoritative_grant_fk
FOREIGN KEY (grant_id, status)
REFERENCES execution_grants (grant_id, status)
FOREIGN KEY (grant_id, status, credential_id, version_id)
REFERENCES execution_grants (
grant_id,
status,
credential_id,
credential_version_id
)
MATCH FULL
DEFERRABLE INITIALLY DEFERRED;
CREATE TABLE jobs (