public.rbac_org_user_permission_sets
Synced from
docs/generated/erd/— do not hand-edit.
Regenerate withbun run docs:erd(needs staging reader), then this script runs automatically.
Labels:docs/db/erd-table-labels.yml· Runbook:docs/runbooks/erd-schema-docs.md
Description
Section titled “Description”Assigns permission sets to a contact within an org (composes on top of their role) — Not: rbac_org_user_roles (the base role grant)
Columns
Section titled “Columns”| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| contact_id | uuid | false | public.contacts | |||
| expires_at | timestamp with time zone | true | ||||
| granted_at | timestamp with time zone | now() | false | |||
| granted_by | uuid | true | public.contacts | |||
| id | uuid | gen_random_uuid() | false | |||
| notes | text | true | ||||
| org_id | text | false | organizations |
|||
| permission_set_id | uuid | false | public.rbac_permission_set_definitions | |||
| revoked_at | timestamp with time zone | true |
Viewpoints
Section titled “Viewpoints”| Name | Definition |
|---|---|
| Identity, Tenancy & RBAC | Org tenancy, contacts/auth linking, seats (organization_users), and M-7 RBAC. Catalog §1. Seat holds presence only — privilege is rbac_org_user_roles, not organization_users.role_type (dropped). First review: contacts ↔ contact_auth ↔ organization_users ↔ rbac_*. |
Constraints
Section titled “Constraints”| Name | Type | Definition |
|---|---|---|
| rbac_org_user_permission_sets_contact_id_fkey | FOREIGN KEY | FOREIGN KEY (contact_id) REFERENCES contacts(id) |
| rbac_org_user_permission_sets_granted_by_fkey | FOREIGN KEY | FOREIGN KEY (granted_by) REFERENCES contacts(id) ON DELETE SET NULL |
| rbac_org_user_permission_sets_org_id_fkey | FOREIGN KEY | FOREIGN KEY (org_id) REFERENCES organizations(id) |
| rbac_org_user_permission_sets_permission_set_id_fkey | FOREIGN KEY | FOREIGN KEY (permission_set_id) REFERENCES rbac_permission_set_definitions(id) |
| rbac_org_user_permission_sets_pkey | PRIMARY KEY | PRIMARY KEY (id) |
Indexes
Section titled “Indexes”| Name | Definition |
|---|---|
| idx_rbac_org_user_permission_sets_contact_active | CREATE INDEX idx_rbac_org_user_permission_sets_contact_active ON public.rbac_org_user_permission_sets USING btree (contact_id) WHERE (revoked_at IS NULL) |
| idx_rbac_org_user_permission_sets_org | CREATE INDEX idx_rbac_org_user_permission_sets_org ON public.rbac_org_user_permission_sets USING btree (org_id) |
| rbac_org_user_permission_sets_active_unique | CREATE UNIQUE INDEX rbac_org_user_permission_sets_active_unique ON public.rbac_org_user_permission_sets USING btree (org_id, contact_id, permission_set_id) WHERE (revoked_at IS NULL) |
| rbac_org_user_permission_sets_pkey | CREATE UNIQUE INDEX rbac_org_user_permission_sets_pkey ON public.rbac_org_user_permission_sets USING btree (id) |
Relations
Section titled “Relations”erDiagram
"public.rbac_org_user_permission_sets" }o--|| "public.contacts" : "FOREIGN KEY (contact_id) REFERENCES contacts(id)"
"public.rbac_org_user_permission_sets" }o--o| "public.contacts" : "FOREIGN KEY (granted_by) REFERENCES contacts(id) ON DELETE SET NULL"
"public.rbac_org_user_permission_sets" }o--|| "public.organizations" : "FOREIGN KEY (org_id) REFERENCES organizations(id)"
"public.rbac_org_user_permission_sets" }o--|| "public.rbac_permission_set_definitions" : "FOREIGN KEY (permission_set_id) REFERENCES rbac_permission_set_definitions(id)"
"public.rbac_org_user_permission_sets" {
uuid contact_id FK ""
uuid granted_by FK ""
text org_id FK ""
uuid permission_set_id FK ""
}
"public.contacts" {
uuid id ""
text primary_org_id FK ""
text source_org_id FK ""
}
"public.organizations" {
text association_id FK ""
uuid default_approval_reviewer_contact_id FK "Org-level fallback reviewer for two-step send (#5698). Routing chain: the sender's own reviewer, then this, then all org admins. NULL means fall through to the admins, which is the pre-#5698 behaviour."
text id ""
text parent_org_id FK "#671 self-referencing hierarchy pointer. NULL = root org. Direct writes are blocked by trg_block_direct_parent_org_id_writes for every role except service_role/postgres/supabase_admin — the only write path for authenticated/interactive callers is public.reparent_organization(). Cycle-prevented by trg_prevent_org_hierarchy_cycle. #quot;Is association#quot; is derived (EXISTS a child), never stored."
}
"public.rbac_permission_set_definitions" {
uuid id ""
text org_id FK ""
}
Generated by tbls

