Skip to content

campaign / bảng đơn lẻ (5) ​

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 campaign.

deal_terms_sets ​

U19-P1-03. Deal participation terms sets (Word B058.R10). Stub source: operator SQL only, no API write. RLS: deal.read / deal.manage holders read (campaign.actor_can_manage()).

public.deal_terms_sets · 9 cột · 5 check · 1 unique · 3 index · 1 policy · 2 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
nametextNOT NULL
versiontextNOT NULL
contenttextNOT NULL
statustextNOT NULL
created_byuuidFK → accounts
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
version_nointegerNOT NULL

Khoá chính: id

Trỏ ra (1):

  • created_by → accounts · ON DELETE RESTRICT

Được trỏ tới (2): campaigns, orders

delivery_milestones ​

P2-06. Group Buy delivery milestones (date range + reward points bp), locked once the campaign leaves DRAFT.

public.delivery_milestones · 15 cột · 7 check · 1 unique · 2 index · 4 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
campaign_iduuidNOT NULLFK → campaigns
campaign_typetextNOT NULLFK → campaigns
milestone_nointegerNOT NULL
delivers_fromdateU19-P1-04. Giao từ ngày (B064.R04), a Vietnam calendar date.
delivers_todateU19-P1-04. Đến ngày (B064.R04), a Vietnam calendar date >= delivers_from.
reward_point_bpinteger
created_byuuidNOT NULLFK → accounts
updated_byuuidNOT NULLFK → accounts
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
nametextU19-P1-04. Tên hiển thị trên App (B064.R02), <= 100; required outside DRAFT (campaign.assert_ready).
labeltextU19-P1-04. Nhãn hiển thị trên App (B064.R03), <= 50; NULL = no label.
reward_valueintegerU19-P1-04. Pi-Point thưởng (B064.R05) in campaigns.reward_unit (bp or points); replaces reward_point_bp.
legacy_unvalidatedbooleanNOT NULLU19-P1-06 GAP-W-CD-11. A pre-U19 milestone numbered above 5; exempted from delivery_milestones_no_max.

Khoá chính: id

Trỏ ra (3):

  • campaign_id, campaign_type → campaigns · ON DELETE CASCADE
  • created_by → accounts · ON DELETE RESTRICT
  • updated_by → accounts · ON DELETE RESTRICT

Được trỏ tới (2): orders, shipments

daily_code_counters ​

PAF-P1-17 BR-C-13 (Product 02/11). Shared per-day code counter: the last number issued per (scope, Vietnam day). Written only by campaign.next_daily_code(); a number never goes down and rows are never deleted. Scopes: campaign (CD, campaigns.code); excess_deposit (DU, PAF-P1-18).

public.daily_code_counters · 4 cột · 2 check · 0 unique · 1 index · 0 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
scopetextNOT NULLPK
daydateNOT NULLPK
last_valueintegerNOT NULL
updated_attimestamptzNOT NULL

Khoá chính: scope, day

Trỏ ra: không có

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

price_tiers ​

P2-06. Tier table per campaign product and policy version: integer VND, non-overlapping ranges, contiguous + open-ended last tier checked at review; immutable once its policy version is frozen.

public.price_tiers · 10 cột · 3 check · 0 unique · 2 index · 3 policy · 2 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
campaign_iduuidNOT NULLFK → campaign_products
campaign_product_iduuidNOT NULLFK → campaign_products
policy_version_iduuidNOT NULLFK → campaign_policy_versions
min_qtyinteger
max_qtyinteger
unit_price_vndbigint
qty_rangeint4range
created_byuuidNOT NULLFK → accounts
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (3):

  • created_by → accounts · ON DELETE RESTRICT
  • policy_version_id, campaign_id → campaign_policy_versions · ON DELETE CASCADE
  • campaign_product_id, campaign_id → campaign_products · ON DELETE CASCADE

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

system_settings ​

U19-P1-03. System configuration parameters (Cấu hình hệ thống), non-secret. Read through settings.get_int / settings.get_text; operator SQL only, no API write.

public.system_settings · 4 cột · 1 check · 0 unique · 1 index · 1 policy · 1 trigger · RLS bật

CộtKiểuKhoáMô tả
keytextNOT NULLPK
valuejsonbNOT NULL
updated_byuuidFK → accounts
updated_attimestamptzNOT NULL

Khoá chính: key

Trỏ ra (1):

  • updated_by → accounts · ON DELETE RESTRICT

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

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17