fix(12): CR-01 widen partner_cost/partner_cost_total to NUMERIC(14,4) to stop silent precision loss
This commit is contained in:
parent
dbc0d5a703
commit
591fc5cf10
1 changed files with 14 additions and 0 deletions
14
migrations/095_pax8_order_items_partner_cost_numeric.sql
Normal file
14
migrations/095_pax8_order_items_partner_cost_numeric.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- Fix: pax8_order_items.partner_cost / partner_cost_total were declared
|
||||
-- NUMERIC(12,2) (migration 093), but real PAX8 per-unit partner costs carry
|
||||
-- 3-4 decimal digits of precision (e.g. cost: 22.176, cost: 0.0182 --
|
||||
-- live-verified sample values from 12-02-SUMMARY.md, exercised in
|
||||
-- lib/services/pax8-sync-service.test.ts). Postgres silently rounds values
|
||||
-- that exceed a column's declared scale rather than rejecting them, so
|
||||
-- NUMERIC(12,2) was quietly corrupting partner-cost data on every insert
|
||||
-- (22.176 -> 22.18, 0.0182 -> 0.02). This is the same class of fix as
|
||||
-- migration 094 (there the column was too narrow in *kind*; here it's too
|
||||
-- narrow in *scale*). Widen to match quantity's NUMERIC(14,4); existing
|
||||
-- 2-decimal-scale rows convert losslessly.
|
||||
|
||||
ALTER TABLE pax8_order_items ALTER COLUMN partner_cost TYPE NUMERIC(14,4) USING partner_cost::numeric;
|
||||
ALTER TABLE pax8_order_items ALTER COLUMN partner_cost_total TYPE NUMERIC(14,4) USING partner_cost_total::numeric;
|
||||
Loading…
Add table
Add a link
Reference in a new issue