wulf-pulse/migrations/094_pax8_order_items_quantity_numeric.sql
lorentz 0e8504c1c1 feat(12-05): live PAX8 orders/matching verification script + quantity fix
- scripts/verify-pax8-orders-matching.ts: runs a real Pax8SyncService.fullSync()
  twice, then asserts all four Phase 12 success criteria (order items
  populated with company id + billing period, confident auto-matches exist,
  no-match/ambiguous companies flagged for review, auto-match set stable
  across two syncs). Never logs secrets/tokens.
- migrations/094_pax8_order_items_quantity_numeric.sql (Rule 1 auto-fix):
  pax8_order_items.quantity was INTEGER but real PAX8 usage-based invoice
  items (e.g. Azure per-unit bandwidth overage) report fractional
  quantities, which aborted the entire orders/order_items sync loop on the
  first such row and silently truncated SC#1's item coverage to ~123 rows
  instead of the full ~56k-row history. Widened to NUMERIC(14,4); applied
  directly to the dev DB (existing volume, not a fresh init).
- deferred-items.md: logged pre-existing out-of-scope failures (appgate
  TS2307 type errors, itglue-search.test.ts) confirmed unchanged by this
  plan's files.
2026-07-10 23:10:44 -04:00

13 lines
828 B
SQL

-- Fix: pax8_order_items.quantity was INTEGER (migration 091), but real PAX8
-- invoice items report fractional quantities for usage-based line items
-- (e.g. Azure per-unit bandwidth overage: quantity=44.7684). A live full sync
-- (12-05 verification) aborted the entire orders/order_items sync loop on
-- the first such row ("invalid input syntax for type integer: 44.7684"),
-- silently truncating SC#1's item coverage to a tiny partial subset instead
-- of the full ~56k-row history. Widen to NUMERIC to accept any PAX8 quantity
-- value; existing integer-valued rows convert losslessly.
--
-- pax8_subscriptions.quantity (seat counts) is untouched — no fractional
-- values observed there and it's out of scope for this fix.
ALTER TABLE pax8_order_items ALTER COLUMN quantity TYPE NUMERIC(14,4) USING quantity::numeric;