Giao diện
loyalty / attribution
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 đè.
4 bảng. Quay lại loyalty.
attribution_touches
P4-11. Append-only link opens (server time, account or opaque visitor key, no IP/PII). SYSTEM_ONLY.
public.attribution_touches · 10 cột · 4 check · 1 unique · 4 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
link_kind | text | NOT NULL | ||
referral_link_id | uuid | FK → referral_links | ||
affiliate_link_id | uuid | FK → affiliate_links | ||
link_owner_account_id | uuid | NOT NULL | FK → accounts | |
account_id | uuid | FK → accounts | ||
visitor_key | text | |||
request_id | text | NOT NULL | ||
touched_at | timestamptz | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL |
Khoá chính: id
Trỏ ra (4):
account_id→accounts·ON DELETE RESTRICTaffiliate_link_id→affiliate_links·ON DELETE RESTRICTlink_owner_account_id→accounts·ON DELETE RESTRICTreferral_link_id→referral_links·ON DELETE RESTRICT
Được trỏ tới (3): attribution_assignments, attribution_touch_bindings, referral_milestones
attribution_assignments
P4-11. One immutable Last-Touch Affiliate decision per Order (snapshot at order creation, team at that time, losing touches, non-attribution reason). Owners read ATTRIBUTED/SELF_PURCHASE rows (masked buyer).
public.attribution_assignments · 23 cột · 7 check · 2 unique · 5 index · 1 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
order_id | uuid | NOT NULL | FK → orders | |
buyer_account_id | uuid | NOT NULL | FK → accounts | |
campaign_id | uuid | NOT NULL | FK → campaigns | |
order_created_at | timestamptz | NOT NULL | ||
outcome | text | NOT NULL | ||
policy_ref | text | |||
policy_version_id | uuid | FK → attribution_policy_versions | ||
window_seconds | integer | |||
basis | text | NOT NULL | ||
last_touch_id | uuid | FK → attribution_touches | ||
affiliate_link_id | uuid | FK → affiliate_links | ||
link_owner_account_id | uuid | FK → accounts | ||
link_owner_app | app_code | |||
link_owner_status | text | |||
link_owner_team_id | uuid | FK → sale_teams | ||
touched_at | timestamptz | |||
window_ends_at | timestamptz | |||
losing_touch_ids | uuid[] | NOT NULL | ||
source_event_id | uuid | NOT NULL | ||
source_event_type | text | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL | ||
recorded_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra (8):
affiliate_link_id→affiliate_links·ON DELETE RESTRICTbuyer_account_id→accounts·ON DELETE RESTRICTcampaign_id→campaigns·ON DELETE RESTRICTlast_touch_id→attribution_touches·ON DELETE RESTRICTlink_owner_account_id→accounts·ON DELETE RESTRICTlink_owner_team_id→sale_teams·ON DELETE RESTRICTorder_id→orders·ON DELETE RESTRICTpolicy_version_id→attribution_policy_versions·ON DELETE RESTRICT
Được trỏ tới (1): point_reward_actions
attribution_policy_versions
P4-11. Immutable Last-Touch window versions (BRD 3 days = 72 h, inclusive boundary); snapshotted per order.
public.attribution_policy_versions · 9 cột · 5 check · 2 unique · 3 index · 1 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
id | uuid | NOT NULL | PK | |
version_no | integer | NOT NULL | ||
model | text | NOT NULL | ||
window_seconds | integer | NOT NULL | ||
window_boundary | text | NOT NULL | ||
effective_from | timestamptz | NOT NULL | ||
source_ref | text | NOT NULL | ||
decision_ref | text | |||
created_at | timestamptz | NOT NULL |
Khoá chính: id
Trỏ ra: không có
Được trỏ tới (1): attribution_assignments
attribution_touch_bindings
FU-716 SPEC-02. Append-only: anonymous Affiliate touch -> the account that signed in on that device inside the window (first claim wins per touch). SYSTEM_ONLY.
public.attribution_touch_bindings · 5 cột · 1 check · 0 unique · 3 index · 0 policy · 2 trigger · RLS bật
| Cột | Kiểu | Khoá | Mô tả | |
|---|---|---|---|---|
touch_id | uuid | NOT NULL | PK FK → attribution_touches | |
account_id | uuid | NOT NULL | FK → accounts | |
visitor_key | text | NOT NULL | ||
bound_at | timestamptz | NOT NULL | ||
correlation_id | correlation_ref | NOT NULL |
Khoá chính: touch_id
Trỏ ra (2):
account_id→accounts·ON DELETE RESTRICTtouch_id→attribution_touches·ON DELETE RESTRICT
Được trỏ tới: không có