Giao diện
identity / account
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 đè.
2 bảng. Quay lại identity.
accounts
P1-01, AF-P2-02. One row per verified phone identity; account_id is the stable PIDEAL identity root (sub of PIDEAL tokens), mapped from providers by identity_links. Unique phone_e164 is the DB guard for concurrent duplicate registration. Status blocks access; it never changes PiPoint/orders.
public.accounts · 12 cột · 8 check · 2 unique · 4 index · 1 policy · 6 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
account_id | uuid | NOT NULL | PK | |
phone_e164 | phone_e164 | E.164 login phone. NULL only for an email-only PiPoint account (PPI-P3-01, E-01); then email_normalized is set. Changes only inside a SECURITY DEFINER function (trigger accounts_identity_change_guard). | ||
phone_verified_at | timestamptz | When the phone was proven (registration OTP, or the first reset/OTP of an Admin-created account). NULL only while provisioned_by is set and the Sale has not proven the phone yet (U6-P2-22, INT-SL-02). Set once. | ||
status | text | NOT NULL | ||
status_reason | text | |||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL | ||
provisioned_by | uuid | FK → accounts | U6-P2-22 (INT-SL-02). The Admin who created this account in Admin (SL-US-03); null for self-registered accounts. Immutable; never the account itself; never the reviewer of the Sale ticket (K-10). | |
kind | text | NOT NULL | PPI-P1-01 (E-05). CUSTOMER (User/Sale App) or STAFF (Web Admin, its own row). Default CUSTOMER; immutable after insert (trigger accounts_kind_immutable). | |
email_normalized | text | PPI-P3-01 (D-05, E-01). Login email from PiPoint, lower case and trimmed; unique; NULL when the account has none. Never used to auto-link (link by phone only). Changes only inside a SECURITY DEFINER function. | ||
deleted_at | timestamptz | PPI-P3-09 (D-12, DEC-PPI-GAP-04). When the customer deleted this account (privacy.delete_own_account); set once. A deleted row has no phone, no email and stays LOCKED (accounts_deleted_shape); its history (orders, payments, audit) keeps the account_id. The next login with the same phone / email / PiPoint uid creates a new account. |
Khoá chính: account_id
Trỏ ra (1):
provisioned_by→accounts·ON DELETE RESTRICT
Được trỏ tới (240): account_sessions, accounts, addresses, affiliate_links, app_memberships, app_memberships, attribution_assignments, attribution_assignments, attribution_touch_bindings, attribution_touches, attribution_touches, audit_events, brands, brands, brands, campaign_delivery_windows, campaign_delivery_windows, campaign_point_config_versions, campaign_point_config_versions, campaign_policy_versions, campaign_products, campaign_products, campaign_state_events, campaign_term_packages, campaign_term_packages và 215 bảng nữa
account_sessions
AF-P2-01. SYSTEM_ONLY PIDEAL session per sign-in and app: refresh token hash (sha256 of the secret), previous hash for the rotation grace, idle and absolute expiry (session-policy), revocation reason. No raw token, IP or user agent is stored.
public.account_sessions · 13 cột · 7 check · 0 unique · 3 index · 0 policy · 1 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
sid | uuid | NOT NULL | PK | |
account_id | uuid | NOT NULL | FK → accounts | |
app | app_code | NOT NULL | ||
created_at | timestamptz | NOT NULL | ||
last_refreshed_at | timestamptz | NOT NULL | ||
idle_expires_at | timestamptz | NOT NULL | ||
absolute_expires_at | timestamptz | |||
refresh_hash | bytea | NOT NULL | ||
previous_refresh_hash | bytea | |||
rotated_at | timestamptz | |||
generation | integer | NOT NULL | ||
revoked_at | timestamptz | |||
revoke_reason | text |
Khoá chính: sid
Trỏ ra (1):
account_id→accounts·ON DELETE RESTRICT
Được trỏ tới: không có