Skip to content

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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
link_kindtextNOT NULL
referral_link_iduuidFK → referral_links
affiliate_link_iduuidFK → affiliate_links
link_owner_account_iduuidNOT NULLFK → accounts
account_iduuidFK → accounts
visitor_keytext
request_idtextNOT NULL
touched_attimestamptzNOT NULL
correlation_idcorrelation_refNOT NULL

Khoá chính: id

Trỏ ra (4):

  • account_id → accounts · ON DELETE RESTRICT
  • affiliate_link_id → affiliate_links · ON DELETE RESTRICT
  • link_owner_account_id → accounts · ON DELETE RESTRICT
  • referral_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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
buyer_account_iduuidNOT NULLFK → accounts
campaign_iduuidNOT NULLFK → campaigns
order_created_attimestamptzNOT NULL
outcometextNOT NULL
policy_reftext
policy_version_iduuidFK → attribution_policy_versions
window_secondsinteger
basistextNOT NULL
last_touch_iduuidFK → attribution_touches
affiliate_link_iduuidFK → affiliate_links
link_owner_account_iduuidFK → accounts
link_owner_appapp_code
link_owner_statustext
link_owner_team_iduuidFK → sale_teams
touched_attimestamptz
window_ends_attimestamptz
losing_touch_idsuuid[]NOT NULL
source_event_iduuidNOT NULL
source_event_typetextNOT NULL
correlation_idcorrelation_refNOT NULL
recorded_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (8):

  • affiliate_link_id → affiliate_links · ON DELETE RESTRICT
  • buyer_account_id → accounts · ON DELETE RESTRICT
  • campaign_id → campaigns · ON DELETE RESTRICT
  • last_touch_id → attribution_touches · ON DELETE RESTRICT
  • link_owner_account_id → accounts · ON DELETE RESTRICT
  • link_owner_team_id → sale_teams · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • policy_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ộtKiểuKhoáMô tả
iduuidNOT NULLPK
version_nointegerNOT NULL
modeltextNOT NULL
window_secondsintegerNOT NULL
window_boundarytextNOT NULL
effective_fromtimestamptzNOT NULL
source_reftextNOT NULL
decision_reftext
created_attimestamptzNOT 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ộtKiểuKhoáMô tả
touch_iduuidNOT NULLPK FK → attribution_touches
account_iduuidNOT NULLFK → accounts
visitor_keytextNOT NULL
bound_attimestamptzNOT NULL
correlation_idcorrelation_refNOT NULL

Khoá chính: touch_id

Trỏ ra (2):

  • account_id → accounts · ON DELETE RESTRICT
  • touch_id → attribution_touches · ON DELETE RESTRICT

Được trỏ tới: không có

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17