Skip to content

order_fulfillment / order ​

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 đè.

14 bảng. Quay lại order_fulfillment.

orders ​

P2-11. Order commitment with an immutable quote snapshot (V0, deposit, point cap/rate, policy version, tiers, milestone, address). State machine + expectedVersion by trigger; OWN read (U-01).

public.orders · 65 cột · 20 check · 3 unique · 16 index · 2 policy · 17 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
owner_account_iduuidNOT NULLFK → order_quotes
request_idtextNOT NULL
quote_iduuidNOT NULLFK → order_quotes
campaign_iduuidNOT NULLFK → campaign_delivery_windows
campaign_typetextNOT NULLFK → campaigns
campaign_versionintegerNOT NULL
policy_version_iduuidNOT NULLFK → campaign_policy_versions
committed_cycle_countintegerNOT NULLFK → campaign_term_packages
v0_vndbigintNOT NULL
deposit_rate_bpintegerNOT NULL
deposit_vndbigintNOT NULL
point_cap_bpintegerNOT NULL
point_cap_policy_versiontextNOT NULL
point_rate_snapshot_vndnumericNOT NULL
point_rate_policy_versiontextNOT NULL
max_pointsintegerNOT NULL
points_usedintegerNOT NULL
points_value_vndbigintNOT NULL
close_rule_reftextNOT NULL
shortage_rule_versionstext[]NOT NULL
tier_snapshotjsonbNOT NULL
quoted_attimestamptzNOT NULL
milestone_iduuidFK → delivery_milestones
milestone_nointeger
milestone_delivers_fromtimestamptz
milestone_delivers_totimestamptz
milestone_reward_point_bpinteger
address_iduuidNOT NULLFK → addresses
ship_recipient_nametextNOT NULL
ship_recipient_phonephone_e164NOT NULL
ship_provincetextNOT NULL
ship_districttextNOT NULL
ship_wardtextNOT NULL
ship_address_linetextNOT NULL
ship_address_typetextNOT NULL
statetextNOT NULL
state_changed_attimestamptzNOT NULL
updated_byuuidFK → accounts
change_sourcetextNOT NULL
change_source_idtextNOT NULL
change_reasontext
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL
codetextNOT NULL#298. Business order code, unique (case-insensitive), immutable. TEMPORARY format PO + 8 A-Z0-9 (ordering.new_order_code(); Product format open: NEW-SL-12). No format CHECK on purpose.
order_statusordering.order_axisNOT NULLU19-P1-07. Word order axis (B013.R02), stored; moved by the order writers and ordering.set_order_axes only.
payment_statusordering.payment_axisNOT NULLU19-P1-07. Word payment axis (B013.R02), stored independently of order_status.
cancel_reasonordering.cancel_reasonU19-P1-07. Why the order is CANCELLED; null for every other status.
confirmed_attimestamptzU19-P1-07. Ngay duyet: when the order became CONFIRMED.
status_versionintegerNOT NULLU19-P1-07. +1 on every write of the axes.
shipping_statusordering.shipping_axisNOT NULLU19-P1-08. Word shipping axis (B013.R02) of a Group Buy order; a Recurring order uses order_cycles.shipping_status.
package_nointegerFK → campaign_term_packagesU19-P1-05. Gói kỳ cam kết chosen for the whole basket (B208.R06); belongs to the campaign with this term.
delivery_window_nointegerFK → campaign_delivery_windowsU19-P1-05. Khung ngày giao chosen by the buyer (B208.R05).
skip_maxintegerU19-P1-05. Snapshot of the package Được bỏ qua tối đa (App skip button only, owner GAP-W-CD-14).
package_reward_valueintegerU19-P1-05. Snapshot of the package Pi-Point thưởng, in the campaign reward unit (B220.R07).
customer_notetextU19-P2-11. Ghi chu cua khach (B036.R02): typed by the buyer when ordering, <= 500 characters; read-only for staff.
address_versionintegerNOT NULLU19-P2-11. Revision of the delivery snapshot (address_id + ship_*). PAF-P1-04 (DEC-PAF-03): the address of an order never changes after creation, so new orders stay at 1; > 1 only on orders changed before PAF-P1-04.
address_updated_attimestamptzU19-P2-11. When the buyer changed the delivery address on the app (before PAF-P1-04, DEC-PAF-03, no change is possible any more); null = the address given at order time.
deposit_basistextNOT NULLU19-P2-36. Copied from the quote: V0 (rows before U19-P2-36, never recomputed) or PAYABLE (Khách phải trả).
terms_acceptedbooleanU19-P2-36. TRUE = the buyer ticked the terms at submit; NULL = not recorded (the App sends no tick yet).
terms_set_iduuidFK → deal_terms_setsU19-P2-36. Điều khoản tham gia Deal set of the campaign the buyer ticked at submit (B006.R15); NULL when not ticked.
participant_ordinalintegerG1S-P0-03 + DEC-OWN30-S1-ORDINAL (BR-MC-02 per owner 30/10, TB-05 / TB-19). Nguoi thu n: the participant count of the Deal (Mua chung) / basket (Mua dinh ky) at the deposit confirmation, buyer included, fixed then; null before. Orders confirmed before 20261229070000 keep the earlier rank rule.
deposit_roundingtextNOT NULLG1S-P1-01. Copied from the quote: CEIL (up to whole VND, BR-APP-06) or HALF_UP (orders before 20261227010000, never recomputed). Not read by the V0 basis.
repriced_from_quote_iduuidFK → order_quotesG1S-P1-04. The quote the buyer saw when submitGroupOrder wrote the order from a fresh quote at the current price (BR-DC-05/07, owner P4); consumed with the order's quote by orders_guard_insert. NULL = the quoted price.

Khoá chính: id

Trỏ ra (11):

  • address_id → addresses · ON DELETE RESTRICT
  • campaign_id, campaign_type → campaigns · ON DELETE RESTRICT
  • milestone_id → delivery_milestones · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • campaign_id, package_no, committed_cycle_count → campaign_term_packages · ON DELETE RESTRICT
  • policy_version_id, campaign_id → campaign_policy_versions · ON DELETE RESTRICT
  • quote_id, owner_account_id → order_quotes · ON DELETE RESTRICT
  • repriced_from_quote_id → order_quotes
  • terms_set_id → deal_terms_sets · ON DELETE RESTRICT
  • updated_by → accounts · ON DELETE RESTRICT
  • campaign_id, delivery_window_no → campaign_delivery_windows · ON DELETE RESTRICT

Được trỏ tới (41): attribution_assignments, cancellation_decisions, cashbook_entries, cod_collections, deposit_checkouts, in_app_events, mission_reversal_evidence, order_activity_log, order_close_outcomes, order_cycle_close_values, order_cycle_cod_rebalances, order_cycle_failed_deliveries, order_cycle_skip_values, order_cycles, order_first_paid_cycles, order_lines, order_payment_expiries, order_period_final_prices, order_periods, order_points_excess_refunds, order_remaining_methods, order_return_cases, order_state_events, payment_obligations, payment_overpayment_cases và 16 bảng nữa

order_cycles ​

P2-11 shape: Recurring cycle commitments (created after the order is LOCKED); skip/forfeit wait for G-CP.

public.order_cycles · 14 cột · 3 check · 2 unique · 5 index · 1 policy · 4 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
cycle_nointegerNOT NULL
recurring_cycle_iduuidNOT NULLFK → recurring_cycles
policy_version_iduuidNOT NULLFK → campaign_policy_versions
statetextNOT NULL
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL
order_statusordering.order_axisNOT NULLU19-P1-08. Word order axis of this cycle (B013.R03).
payment_statusordering.payment_axisNOT NULLU19-P1-08. Word payment axis of this cycle (B013.R03).
shipping_statusordering.shipping_axisNOT NULLU19-P1-08. Word shipping axis of this cycle (B013.R03).
status_versionintegerNOT NULLU19-P1-08. +1 on every write of the cycle axes.
delivered_equivalentbooleanNOT NULLU19-P2-24. A cycle paid in full whose last delivery failed counts as delivered (DH-US-14 AC05, GAP-W-DH-08).

Khoá chính: id

Trỏ ra (3):

  • order_id → orders · ON DELETE RESTRICT
  • policy_version_id → campaign_policy_versions · ON DELETE RESTRICT
  • recurring_cycle_id → recurring_cycles · ON DELETE RESTRICT

Được trỏ tới (9): cod_collections, order_cycle_close_values, order_cycle_cod_rebalances, order_cycle_failed_deliveries, order_cycle_skip_values, payment_obligations, recurring_forfeit_effects, recurring_skip_requests, shipment_order_links

order_periods ​

P2-13. Committed periods of a Recurring order with the order-time (V0) allocation of deposit + points from the last period backwards; immutable, written by the order insert only. Not a Cycle Commitment.

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

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
cycle_nointegerNOT NULL
recurring_cycle_iduuidNOT NULLFK → recurring_cycles
policy_version_iduuidNOT NULLFK → campaign_policy_versions
delivers_fromtimestamptzNOT NULL
delivers_totimestamptzNOT NULL
value_vndbigintNOT NULL
prepaid_vndbigintNOT NULL
due_vndbigint
allocation_basistextNOT NULL
allocation_ruletextNOT NULLPAY-BRULE-26 (equal periods), BR-DK-08 (U19-P2-37: Pi-Point evenly over the periods with goods) or ACTUAL_PRICE (U28-P2-01 DEC-U28-01: Pi-Point by the line values, actual unit price ceil on the first units, deposit last -> first on V_c, COD ⌈due⌉ to 1,000đ balanced on the last period still to collect, so rounding_vnd may be negative there).
created_attimestamptzNOT NULL
points_value_vndbigintU19-P2-37. Pi-Point value of the period (even split, GAP-W-CD-17); prepaid_vnd - points_value_vnd = its deposit share.
rounding_vndbigintNOT NULLU19-P2-37. What rounding the COD of the period up to 1,000đ adds: COD = due_vnd + rounding_vnd (B208.R09).

Khoá chính: id

Trỏ ra (3):

  • order_id → orders · ON DELETE RESTRICT
  • policy_version_id → campaign_policy_versions · ON DELETE RESTRICT
  • recurring_cycle_id → recurring_cycles · ON DELETE RESTRICT

Được trỏ tới (4): order_cycle_lines, order_period_final_prices, recurring_forfeit_reviews, recurring_skip_requests

order_close_outcomes ​

P2-15. Immutable per-Order Group close result: LOCK with final price / remaining / offline excess, or CANCEL with the full refund intent (cash deposit + original points) for P3. OWN read (U-01).

public.order_close_outcomes · 26 cột · 4 check · 1 unique · 4 index · 1 policy · 5 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
outcome_iduuidNOT NULLFK → campaign_outcomes
campaign_iduuidNOT NULLFK → campaign_policy_versions
order_iduuidNOT NULLFK → orders
owner_account_iduuidNOT NULLFK → accounts
policy_version_iduuidNOT NULLFK → campaign_policy_versions
decisiontextNOT NULL
from_versionintegerNOT NULL
to_versionintegerNOT NULL
unitsbigintNOT NULL
deposit_vndbigintNOT NULL
points_usedintegerNOT NULL
points_value_vndbigintNOT NULL
final_unit_price_vndbigint
final_total_vndbigint
remaining_vndbigint
excess_vndbigint
refund_cash_vndbigint
refund_pointsinteger
refund_rule_reftext
recorded_attimestamptzNOT NULL
actual_total_vndbigintG1S-P1-02 (BR-APP-08). Tổng giá thực tế = final total - min(Pi-Point value, final total), not rounded. Null on rows closed before 20261227010100.
actual_unit_price_vndbigintG1S-P1-02 (GAP-G1S-06). Giá thực tế = ceil(actual total / units), rounded UP to 1đ; never shown to the buyer.
actual_ceil_unitsbigintG1S-P1-02 (GAP-G1S-06). Units carrying actual_unit_price_vnd; the others carry it - 1, so they sum to actual total.
rounding_vndbigintG1S-P1-02 (BR-APP-08, BR-MC-05). What rounding the remaining UP to 1,000đ adds: remaining = max(actual total - deposit, 0) + rounding_vnd (0 <= r < 1,000).
excess_pointsintegerG1S-P1-02 (BR-APP-08, TB-12). Pi-Point above the final order value, returned to the wallet (order_points_excess_refunds).

Khoá chính: id

Trỏ ra (4):

  • order_id → orders · ON DELETE RESTRICT
  • outcome_id, campaign_id → campaign_outcomes · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • policy_version_id, campaign_id → campaign_policy_versions · ON DELETE RESTRICT

Được trỏ tới (2): order_points_excess_refunds, payment_overpayment_cases

order_lines ​

P2-11. Immutable order lines (Campaign Product, quantity, order-time tier price, line V0), copied from the quote.

public.order_lines · 18 cột · 5 check · 2 unique · 4 index · 1 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
line_nointegerNOT NULL
campaign_iduuidNOT NULLFK → campaign_products
campaign_product_iduuidNOT NULLFK → campaign_products
product_iduuidNOT NULLFK → products
sku_snapshottextNOT NULL
name_snapshottext
quantityintegerNOT NULL
cycle_countintegerNOT NULL
committed_unitsbigintNOT NULL
basis_unitsbigintNOT NULL
tier_min_qtyintegerNOT NULL
tier_max_qtyinteger
unit_price_vndbigintNOT NULL
line_v0_vndbigintNOT NULL
created_attimestamptzNOT NULL
unitsbigintNOT NULLG2I-P2-01 (G2-06). Quantity over every cycle of the order (Σ ordering.cycle_lines); quantity stays the default per cycle. Mua chung: units = quantity. Basis, V0 and the committed quantity (MOQ, Tổng) read it.

Khoá chính: id

Trỏ ra (3):

  • campaign_product_id, campaign_id → campaign_products · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • product_id → products · ON DELETE RESTRICT

Được trỏ tới (2): order_cycle_lines, order_period_final_prices

order_quotes ​

P2-11. Immutable server quote bound to a campaign/policy snapshot (OWN_ROW). Only OPEN -> USED by the order insert; expiry is expires_at (required TTL config). Deposit = d x V0 exactly; points separate.

public.order_quotes · 32 cột · 13 check · 1 unique · 5 index · 2 policy · 5 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
owner_account_iduuidNOT NULLFK → accounts
campaign_iduuidNOT NULLFK → campaign_delivery_windows
campaign_typetextNOT NULLFK → campaigns
campaign_versionintegerNOT NULL
policy_version_iduuidNOT NULLFK → campaign_policy_versions
cycle_countintegerNOT NULLFK → campaign_term_packages
linesjsonbNOT NULL
tier_snapshotjsonb
v0_vndbigintNOT NULL
deposit_rate_bpintegerNOT NULL
deposit_vndbigintNOT NULL
point_cap_bpintegerNOT NULL
point_cap_policy_versiontextNOT NULL
point_rate_snapshot_vndnumericNOT NULL
point_rate_policy_versiontextNOT NULL
max_pointsintegerNOT NULL
points_usedintegerNOT NULL
points_value_vndbigintNOT NULL
close_rule_reftextNOT NULL
shortage_rule_versionstext[]NOT NULL
statustextNOT NULL
created_attimestamptzNOT NULL
expires_attimestamptzNOT NULL
versionintegerNOT NULL
basket_iduuidFK → recurring_baskets
basket_versioninteger
deposit_basistextNOT NULLU19-P2-36. V0: deposit = V0 x rate exactly (legacy, Mua định kỳ until U19-P2-37); PAYABLE: deposit = round((V0 - points value) x rate) (Word DH B013.R04 Quy tắc 3, CD B006.R08/R09).
package_nointegerFK → campaign_term_packagesU19-P2-37. Gói kỳ cam kết of a Mua định kỳ quote (B208.R06); the order copies it.
delivery_window_nointegerFK → campaign_delivery_windowsU19-P2-37. Khung ngày giao chosen at the quote (B208.R05); the order copies it.
cycle_linesjsonbNOT NULLG2I-P2-01 (G2-06). Sparse per-cycle quantities [{cycleNo, campaignProductId, quantity}] that differ from the line quantity; the order copies them into order_cycle_lines. '[]' = every cycle at the default.
deposit_roundingtextNOT NULLG1S-P1-01. PAYABLE deposit rounding: CEIL = up to whole VND (FuncSpec 27/10 BR-APP-06, DEC-OWN27-DEPOSIT-CEIL, every new quote); HALF_UP = quotes written before 20261227010000 (never recomputed). Not read by the V0 basis.

Khoá chính: id

Trỏ ra (6):

  • basket_id, campaign_id → recurring_baskets · ON DELETE RESTRICT
  • campaign_id, campaign_type → campaigns · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • campaign_id, package_no, cycle_count → campaign_term_packages · ON DELETE RESTRICT
  • policy_version_id, campaign_id → campaign_policy_versions · ON DELETE RESTRICT
  • campaign_id, delivery_window_no → campaign_delivery_windows · ON DELETE RESTRICT

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

order_activity_cutover ​

U19-P1-09. When each legacy history branch moved to public.order_activity_log (legacy rows before it stay read).

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

CộtKiểuKhoáMô tả
branchtextNOT NULLPK
cutover_attimestamptzNOT NULL
tasktextNOT NULL

Khoá chính: branch

Trỏ ra: không có

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

order_activity_log ​

U19-P1-09. Append-only log of every action on an order (B013.R10, NFR #8); written by ordering.log_activity only.

public.order_activity_log · 13 cột · 4 check · 0 unique · 2 index · 0 policy · 2 trigger · RLS bật

CộtKiểuKhoáMô tả
idbigintNOT NULLPK
order_iduuidNOT NULLFK → orders
cycle_nointeger
categorytextNOT NULL
actiontextNOT NULL
actor_kindtextNOT NULL
actor_account_iduuidFK → accounts
actor_label_snapshottext
actor_roles_snapshottext[]
from_valuetext
to_valuetext
notetext
occurred_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (2):

  • actor_account_id → accounts · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT

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

order_cycle_lines ​

G2I-P2-01 (G2-06, DEC-OWN22-G2-06). Sparse per-cycle quantity of a Recurring order line where it differs from order_lines.quantity, copied from the quote by the order insert; immutable (no edit after ordering, E5).

public.order_cycle_lines · 5 cột · 1 check · 0 unique · 1 index · 1 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
order_iduuidNOT NULLPK FK → order_periods
cycle_nointegerNOT NULLPK FK → order_periods
order_line_iduuidNOT NULLPK FK → order_lines
quantityintegerNOT NULL
created_attimestamptzNOT NULL

Khoá chính: order_id, cycle_no, order_line_id

Trỏ ra (2):

  • order_line_id → order_lines · ON DELETE RESTRICT
  • order_id, cycle_no → order_periods · ON DELETE RESTRICT

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

order_first_paid_cycles ​

FU-AC-TRIAGE L7 PAY-R1-05 HC02 / A-LOY-04 AC07. Immutable: the first actually paid cycle of a Recurring order (COD delivered AND collected, or the one online remaining), the milestone the order reward is released on once. Closed to every login.

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

CộtKiểuKhoáMô tả
order_iduuidNOT NULLPK FK → orders
cycle_nointeger
sourcetextNOT NULL
source_event_iduuidNOT NULL
paid_attimestamptzNOT NULL
recorded_attimestamptzNOT NULL

Khoá chính: order_id

Trỏ ra (1):

  • order_id → orders · ON DELETE RESTRICT

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

order_period_final_prices ​

FU-AC-TRIAGE L7 UA-14 AC01. Immutable: the one final unit price of each product applied to every committed period of every counted order of a CONFIRMED Recurring close. Orders, deposits and obligations are untouched (AC02).

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

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
outcome_iduuidNOT NULLFK → campaign_outcomes
campaign_iduuidNOT NULLFK → campaign_outcomes
order_iduuidNOT NULLFK → order_periods
cycle_nointegerNOT NULLFK → order_periods
order_line_iduuidNOT NULLFK → order_lines
campaign_product_iduuidNOT NULL
quantityintegerNOT NULL
order_unit_price_vndbigintNOT NULL
final_unit_price_vndbigintNOT NULL
final_value_vndbigintNOT NULL
recorded_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (4):

  • order_id → orders · ON DELETE RESTRICT
  • order_line_id → order_lines · ON DELETE RESTRICT
  • outcome_id, campaign_id → campaign_outcomes · ON DELETE RESTRICT
  • order_id, cycle_no → order_periods · ON DELETE RESTRICT

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

order_remaining_methods ​

U19-P2-21 (B013.R11). The buyer's remaining payment method (ONLINE | COD) of an order after the close; no row after the close = COD. Written only by payment.buyer_select_remaining_method (and the FU-F3 pre-close Recurring fact).

public.order_remaining_methods · 8 cột · 3 check · 0 unique · 1 index · 0 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
order_iduuidNOT NULLPK FK → orders
methodtextNOT NULL
source_idtextNOT NULL
created_attimestamptzNOT NULL
chosen_attimestamptz
chosen_byuuidFK → accountsU19-P2-21. The buyer who chose; null for a backfilled row.
versionintegerNOT NULLU19-P2-21. +1 on every change of the choice.
updated_attimestamptzNOT NULL

Khoá chính: order_id

Trỏ ra (2):

  • chosen_by → accounts · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT

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

order_return_cases ​

FU-OIFF01. RETURN case of one Order whose COD was refused (OI-FF-01 decided 2026-10-05): shipment RETURNED, stored refusal fact, COD never collected. Order LOCKED -> CANCELLED, COD obligation cancelled, Pending reward cancelled; deposit and points disposition UNDECIDED (GAP-1321). Immutable; moves no money and no points.

public.order_return_cases · 30 cột · 11 check · 2 unique · 6 index · 2 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
shipment_iduuidNOT NULLFK → shipments
cod_collection_iduuidNOT NULLFK → cod_collections
owner_account_iduuidNOT NULLFK → accounts
campaign_iduuidNOT NULLFK → campaigns
campaign_typetextNOT NULL
case_typetextNOT NULL
causetextNOT NULL
reasontextNOT NULL
evidence_media_idsuuid[]NOT NULL
refusal_sourcetextNOT NULL
refusal_refuuidNOT NULL
returned_attimestamptzNOT NULL
cod_statustextNOT NULL
cod_amount_due_vndbigintNOT NULL
deposit_vndbigintNOT NULL
points_usedintegerNOT NULL
points_value_vndbigintNOT NULL
from_versionintegerNOT NULL
to_versionintegerNOT NULL
policy_reftextNOT NULL
deposit_dispositiontextNOT NULL
points_dispositiontextNOT NULL
reward_dispositiontextNOT NULL
undecided_reftext
recorded_byuuidNOT NULLFK → accounts
source_event_idtextNOT NULL
recorded_attimestamptzNOT NULL
versionintegerNOT NULL

Khoá chính: id

Trỏ ra (6):

  • campaign_id → campaigns · ON DELETE RESTRICT
  • cod_collection_id → cod_collections · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • owner_account_id → accounts · ON DELETE RESTRICT
  • recorded_by → accounts · ON DELETE RESTRICT
  • shipment_id → shipments · ON DELETE RESTRICT

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

order_state_events ​

P2-11. Append-only order history: one row per order version (CREATED / TRANSITIONED, source, actor, reason).

public.order_state_events · 14 cột · 4 check · 2 unique · 5 index · 1 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
order_iduuidNOT NULLFK → orders
order_versionintegerNOT NULL
event_typetextNOT NULL
from_statetext
to_statetextNOT NULL
policy_version_iduuidNOT NULLFK → campaign_policy_versions
sourcetextNOT NULL
source_event_idtextNOT NULL
actor_account_iduuidFK → accounts
reasontext
recorded_attimestamptzNOT NULL
actor_labeltextU13-FU-06. Actor profile full name at insert time (null: no actor, no profile, or a row older than the snapshot).
actor_rolestext[]U13-FU-06. Actor ACTIVE WEB_ADMIN role codes at insert time (null: no actor, or a row older than the snapshot).

Khoá chính: id

Trỏ ra (3):

  • actor_account_id → accounts · ON DELETE RESTRICT
  • order_id → orders · ON DELETE RESTRICT
  • policy_version_id → campaign_policy_versions · ON DELETE RESTRICT

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

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17