-- RBAC step 3: a request to grant an administration capability to one -- member waits here for a second person (four-eyes). A grant of any other -- capability is written to Keycloak at once and never lands here. The row -- is deleted when the request is approved, rejected or withdrawn, or the -- member leaves; the audit log keeps the history. CREATE TABLE capability_requests ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE, user_id TEXT NOT NULL CHECK (char_length(user_id) BETWEEN 1 AND 200), user_email TEXT NOT NULL DEFAULT '' CHECK (char_length(user_email) <= 320), capability TEXT NOT NULL CHECK (capability ~ '^[a-z]+:[a-z0-9-]+\.[a-z0-9-]+$'), requested_by TEXT NOT NULL CHECK (char_length(requested_by) BETWEEN 1 AND 200), requested_email TEXT NOT NULL DEFAULT '' CHECK (char_length(requested_email) <= 320), created_at TIMESTAMPTZ NOT NULL DEFAULT now(), UNIQUE (tenant_id, user_id, capability) );