Giao diện
identity / role
Trang sinh tự động
Sinh từ ad83b0aea — chạy 820 migration lên PostgreSQL 17 rồi đọc pg_catalog. Mô tả bảng và cột lấy từ COMMENT ON. Không sửa tay: lần chạy docgen sau sẽ ghi đè.
5 bảng. Quay lại identity.
roles
Chưa có mô tả — bảng này chưa có COMMENT ON TABLE.
public.roles · 9 cột · 3 check · 2 unique · 3 index · 1 policy · 4 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
app | app_code | NOT NULL | ||
code | text | NOT NULL | ||
name | text | NOT NULL | ||
description | text | |||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL | ||
is_system | boolean | NOT NULL | P1-06. PD-08 s14 baseline role seeded from the permission matrix; immutable through the API. |
Khoá chính: id
Trỏ ra: không có
Được trỏ tới (4): role_assignments, role_change_requests, role_permission_grants, role_versions
role_assignments
Chưa có mô tả — bảng này chưa có COMMENT ON TABLE.
public.role_assignments · 14 cột · 5 check · 0 unique · 3 index · 1 policy · 5 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
account_id | uuid | NOT NULL | FK → app_memberships | |
app | app_code | NOT NULL | FK → roles | |
role_id | uuid | NOT NULL | FK → roles | |
granted_by | uuid | NOT NULL | FK → accounts | |
approved_by | uuid | FK → accounts | ||
grant_reason | text | NOT NULL | ||
granted_at | timestamptz | NOT NULL | ||
revoked_at | timestamptz | |||
revoked_by | uuid | FK → accounts | ||
revoke_reason | text | |||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL |
Khoá chính: id
Trỏ ra (5):
approved_by→accounts·ON DELETE RESTRICTgranted_by→accounts·ON DELETE RESTRICTaccount_id, app→app_memberships·ON DELETE RESTRICTrevoked_by→accounts·ON DELETE RESTRICTrole_id, app→roles·ON DELETE RESTRICT
Được trỏ tới (3): rbac_bootstrap_runs, rbac_bootstrap_runs, role_change_requests
role_change_requests
P1-06. Maker/checker RBAC changes (AD-01 request, AD-02 approve). PENDING -> APPROVED once; payload immutable.
public.role_change_requests · 22 cột · 13 check · 0 unique · 4 index · 0 policy · 6 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
kind | text | NOT NULL | ||
app | app_code | NOT NULL | FK → app_memberships | |
role_id | uuid | NOT NULL | FK → roles | |
role_version | integer | NOT NULL | ||
account_id | uuid | FK → app_memberships | ||
assignment_id | uuid | FK → role_assignments | ||
grants | jsonb | |||
payload_hash | text | NOT NULL | ||
reason | text | NOT NULL | ||
status | text | NOT NULL | ||
requested_by | uuid | NOT NULL | FK → accounts | |
requested_at | timestamptz | NOT NULL | ||
approved_by | uuid | FK → accounts | ||
approved_at | timestamptz | |||
applied_version | integer | |||
correlation_id | correlation_ref | |||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL | ||
rejected_by | uuid | FK → accounts | PPI-P7-01. Who rejected the request (rejectMembership of a new staff member); never the maker nor the person. | |
rejected_at | timestamptz |
Khoá chính: id
Trỏ ra (6):
approved_by→accounts·ON DELETE RESTRICTassignment_id→role_assignments·ON DELETE RESTRICTrejected_by→accounts·ON DELETE RESTRICTrequested_by→accounts·ON DELETE RESTRICTrole_id, app→roles·ON DELETE RESTRICTaccount_id, app→app_memberships·ON DELETE RESTRICT
Được trỏ tới (2): role_permission_grants, role_versions
role_versions
P1-06. APPEND_ONLY snapshot of every role version (name/description/system flag, who, which request).
public.role_versions · 11 cột · 1 check · 0 unique · 1 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
role_id | uuid | NOT NULL | PK FK → roles | |
version | integer | NOT NULL | PK | |
app | app_code | NOT NULL | ||
code | text | NOT NULL | ||
name | text | NOT NULL | ||
description | text | |||
is_system | boolean | NOT NULL | ||
changed_by | uuid | FK → accounts | ||
change_request_id | uuid | FK → role_change_requests | ||
recorded_at | timestamptz | NOT NULL | ||
recorded_xact | xid8 | NOT NULL |
Khoá chính: role_id, version
Trỏ ra (3):
change_request_id→role_change_requests·ON DELETE RESTRICTchanged_by→accounts·ON DELETE RESTRICTrole_id→roles·ON DELETE RESTRICT
Được trỏ tới (2): role_permission_grants, role_permission_grants
role_permission_grants
P1-06. Role -> permission + scope, as intervals over role versions. Live = revoked_in_version IS NULL.
public.role_permission_grants · 10 cột · 4 check · 0 unique · 3 index · 0 policy · 6 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
role_id | uuid | NOT NULL | FK → roles | |
permission_id | uuid | NOT NULL | FK → permissions | |
scope | text | NOT NULL | ||
granted_in_version | integer | NOT NULL | FK → role_versions | |
revoked_in_version | integer | FK → role_versions | ||
origin | text | NOT NULL | ||
matrix_rule_ids | text[] | NOT NULL | ||
change_request_id | uuid | FK → role_change_requests | ||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (5):
change_request_id→role_change_requests·ON DELETE RESTRICTrole_id, granted_in_version→role_versions·ON DELETE RESTRICTpermission_id→permissions·ON DELETE RESTRICTrole_id, revoked_in_version→role_versions·ON DELETE RESTRICTrole_id→roles·ON DELETE RESTRICT
Được trỏ tới: không có