Giao diện
loyalty / referral
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 đè.
3 bảng. Quay lại loyalty.
referral_links
P4-11. Personal Referral link per (owner account, app): opaque code, ACTIVE|DISABLED, version. OWN read.
public.referral_links · 12 cột · 5 check · 1 unique · 3 index · 1 policy · 3 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
owner_account_id | uuid | NOT NULL | FK → app_memberships | |
owner_app | app_code | NOT NULL | FK → app_memberships | |
code | text | NOT NULL | ||
status | text | NOT NULL | ||
disabled_at | timestamptz | |||
disabled_by | uuid | FK → accounts | ||
disabled_reason | text | |||
correlation_id | correlation_ref | NOT NULL | ||
created_at | timestamptz | NOT NULL | ||
updated_at | timestamptz | NOT NULL | ||
version | integer | NOT NULL |
Khoá chính: id
Trỏ ra (2):
disabled_by→accounts·ON DELETE RESTRICTowner_account_id, owner_app→app_memberships·ON DELETE RESTRICT
Được trỏ tới (2): attribution_touches, referral_milestones
referral_milestones
P4-11. Referral SIGNUP (Last-Touch at sign-up) + EKYC_VERIFIED / FIRST_PAID records, once per person. No reward.
public.referral_milestones · 14 cột · 5 check · 2 unique · 4 index · 1 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
referred_account_id | uuid | NOT NULL | FK → accounts | |
milestone | text | NOT NULL | ||
referral_link_id | uuid | NOT NULL | FK → referral_links | |
referrer_account_id | uuid | NOT NULL | FK → accounts | |
referrer_app | app_code | NOT NULL | ||
referrer_team_id | uuid | FK → sale_teams | ||
signup_touch_id | uuid | FK → attribution_touches | ||
signup_milestone_id | uuid | FK → referral_milestones | ||
occurred_at | timestamptz | NOT NULL | ||
source_type | text | NOT NULL | ||
source_id | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL | ||
recorded_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (6):
referral_link_id→referral_links·ON DELETE RESTRICTreferred_account_id→accounts·ON DELETE RESTRICTreferrer_account_id→accounts·ON DELETE RESTRICTreferrer_team_id→sale_teams·ON DELETE RESTRICTsignup_milestone_id→referral_milestones·ON DELETE RESTRICTsignup_touch_id→attribution_touches·ON DELETE RESTRICT
Được trỏ tới (1): referral_milestones
referral_identity_keys
P4-12. SHA-256 of the verified eKYC identity of a referred account: one person = one referral. SYSTEM_ONLY.
public.referral_identity_keys · 6 cột · 2 check · 1 unique · 2 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
identity_hash | text | NOT NULL | PK | |
referred_account_id | uuid | NOT NULL | FK → accounts | |
source_type | text | NOT NULL | ||
source_id | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL | ||
recorded_at | timestamptz | NOT NULL |
Khoá chính: identity_hash
Trỏ ra (1):
referred_account_id→accounts·ON DELETE RESTRICT
Được trỏ tới: không có