diff --git a/.planning/phases/10-pax8-client-auth-foundation/10-02-PLAN.md b/.planning/phases/10-pax8-client-auth-foundation/10-02-PLAN.md index 9826ec7..2f2cc4e 100644 --- a/.planning/phases/10-pax8-client-auth-foundation/10-02-PLAN.md +++ b/.planning/phases/10-pax8-client-auth-foundation/10-02-PLAN.md @@ -11,10 +11,12 @@ requirements: [PAX8-01, PAX8-02] must_haves: truths: - - "Migration 091 creates all six PAX8 tables: pax8_companies, pax8_subscriptions, pax8_products, pax8_orders, pax8_order_items, pax8_company_match_review" + - "(D-01) Two-table header/line-item design: pax8_orders (order id, company, order date, total, status) + pax8_order_items (order_id FK, product/SKU, quantity, unit price, line total) — migration 091 creates all six PAX8 tables: pax8_companies, pax8_subscriptions, pax8_products, pax8_orders, pax8_order_items, pax8_company_match_review" - "Every table is created with IF NOT EXISTS so the migration is idempotent on re-apply (no error on second run)" - "pax8_order_items.order_id is a hard FK to pax8_orders(id) ON DELETE CASCADE (header/line relationship)" - "pax8_company_match_review carries candidate_company_ids BIGINT[], match_confidences TEXT[], a hard FK to pax8_companies(id) ON DELETE CASCADE, and a nullable resolved_to_company_id BIGINT REFERENCES companies(id)" + - "(D-02) No lookback-window bound — no 'earliest synced' or window-config column is added; sync pulls full order history on first sync in a later phase" + - "(D-03) pax8_orders and pax8_order_items both carry a raw_payload JSONB column as a safety net for PAX8 fields not yet modeled, alongside typed columns" - "Monetary columns are NUMERIC(12,2) with a companion currency CHAR(3) DEFAULT 'USD' (D-04); orders/order_items pricing+status columns carry PAX8 Invoice/InvoiceItem semantics, flagged inline (RESEARCH Pitfall 1)" - "Each of the four primary entity tables carries raw_payload JSONB + synced_at + is_deleted + deleted_at audit columns and an idx_