One Rollen- und Befugnisdatensatz per company (docgen#1 plan 13781 §3.2
no. 2, owner addendum 13791): functions, who holds them, deputies with
their basis, the deciding function per decision type, immediate
authority, standard releases, named editors and the contact path for
critical security events.
- internal/roles: the catalogue in code (version r1-2026-10-26.1), the
union of A1 §2.3 and A4 §4 = 21 functions, 14 customer decision types;
only the three releases carry an owner default (management), the rest
must be set by the company.
- Rules: a deputy is wirksam only with a documented basis, within its
validity and, where it covers management authority, with management's
authorization (B7 wording: what management records it has authorized);
another release body for R1-D02 updates only with the R1-D02 provision
(B8); management and document owners write, the OWNER sign-in role may
only record the first management holder; recorded_*/authorized_* are
stamped from the token, never from the body; no self-authorization.
- Routes: GET/PUT /v1/tenants/{id}/role-dataset, GET …/revisions/{rev},
GET …/resolve. Writes need the user's token; user tokens on these
routes form route group role-dataset.user, so the portal's sign-in
client needs no tenants grant.
- Migration 0024: role_datasets and role_dataset_revisions, versioned as
the company profile (expected_revision, 409 on conflict).
- Audit role_dataset.saved with revision and changed entry ids only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
26 lines
1.3 KiB
SQL
26 lines
1.3 KiB
SQL
-- Rollen- und Befugnisdatensatz (R1 S0, docgen#1 13781 §3.2 no. 2, owner
|
|
-- addendum 13791): one document per company with functions, assignments,
|
|
-- deputies and the authority per decision type. The registry checks the
|
|
-- structure and the rules of B7/B8; the catalogue of functions lives in code
|
|
-- (internal/roles).
|
|
CREATE TABLE role_datasets (
|
|
tenant_id UUID PRIMARY KEY REFERENCES tenants(id) ON DELETE CASCADE,
|
|
data JSONB NOT NULL CHECK (jsonb_typeof(data) = 'object'),
|
|
catalogue_version TEXT NOT NULL CHECK (char_length(catalogue_version) BETWEEN 1 AND 40),
|
|
revision INTEGER NOT NULL CHECK (revision >= 1),
|
|
updated_by TEXT NOT NULL, -- Keycloak sub of the writer
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
-- Every saved state, never changed afterwards. A decision record names the
|
|
-- revision it was made under (AK-G7, AK-V5).
|
|
CREATE TABLE role_dataset_revisions (
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
revision INTEGER NOT NULL CHECK (revision >= 1),
|
|
data JSONB NOT NULL,
|
|
catalogue_version TEXT NOT NULL,
|
|
changed_by TEXT NOT NULL,
|
|
changed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (tenant_id, revision)
|
|
);
|