2.1 KiB
2.1 KiB
F-144 — Criterios de aceptación
AC1 — store_id multi-tienda (snapshot, no rewrite)
orders_orders.store_idesuuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000001'::uuid.- FK
orders_orders_store_id_fkey → pos_stores(id)existe y esVALID. - Índice
orders_orders_store_id_created_at_idx ON orders_orders(store_id, created_at)existe. - Filas existentes heredan el default store (no table rewrite de datos).
- Un
INSERT INTO orders_orders DEFAULT VALUESpersistestore_id = DEFAULT_STORE_ID.
AC2 — shipping_cents separado
orders_orders.shipping_centsesinteger NOT NULL DEFAULT 0.- Filas existentes mantienen su
total_cents(no se altera; shipping_cents = 0). - El
INSERT ... DEFAULT VALUESregistrashipping_cents = 0.
AC3 — snapshots de línea (cost_at_sale_cents, vat_rate)
orders_items.cost_at_sale_centsesbigint, nullable (NULL para filas históricas → margenunavailable).orders_items.vat_rateestext, nullable (snapshot del tipo IVA aplicado; NULL → IVA-por-tipounavailable).- No se reescribe la historia: columnas nuevas no tocan datos existentes.
AC4 — migración idempotente y reversible
up()es no-op si se re-ejecuta (DDLIF NOT EXISTS/DO $$guards).down()elimina índice, constraint y columnas nuevas.
AC5 — itest de snapshots (DB real)
reporting-snapshots.itest.tsrecrea la DB, migra (aplica 048), y verifica columnas, nullabilidad, defaults, FK (contype='f') e índice víainformation_schema/pg_constraint/pg_indexes, más un insertDEFAULT VALUEScon backfill destore_id/shipping_cents.
AC6 — verificación de gates
npx tsc --noEmit→ 0 errores.TEST_DATABASE_URL=... npx vitest run→ itest F-144 3/3 verde + sin regresiones (orders/catalog/checkout/sales/etc.) 0 fallos.node scripts/check-module-boundaries.mjs src→ 0 violaciones nuevas.
AC7 — sin regresión en flujos existentes
- El seed y el checkout siguen funcionando:
orders_ordersINSERTsinstore_idexplícito sigue válido (column DEFAULT). orders.itest.ts,catalog.itest.ts,checkout-flow.itest.tssiguen verdes.