2.3 KiB
0pt order-ownership cutover
Status: source implementation in PR #66; not applied to production. Canonical design: ADR-001.
Dependency order
-
Confirm the target Postgres is the canonical 0pt order store. Capture a recoverable database snapshot and identify current migration state.
sql/001_init.sqlandsql/006_orders_idempotency.sqlmust already be present; this repository has no general automated migration runner yet. -
Apply
sql/011_orders_tenant_ownership.sqltransactionally to staging, then production only after staging verification. The file is idempotent and leaves legacy NULL-owned rows untouched. For an environment whereDATABASE_URLis securely injected, a manual controlled step is:psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f sql/011_orders_tenant_ownership.sql -
Verify
orders.tenant_id,orders.buyer_subject, the ownership-pair check constraint andorders_tenant_created_idx. Record migration output and deployment SHA in the rollout evidence. Do not deploy the tenant-scoped source before the schema is verified; an undefined column will fail requests. -
Wire a real Zitadel customer UI session and send the verified credential to every order/payment API call. Existing dev HMAC login is not a payment identity. Keep anonymous composition as an estimate only.
-
In staging, prove: no token -> 401; spoofed tenant header -> 401/403; another tenant's order -> 404; legacy unowned order -> 404/unpayable; matching signed paid Stripe event -> correct status; unpaid/mismatched event -> no status change; repeat delivery -> idempotent. Test purchase, cancellation and refund with real sandbox endpoints. Only then review SIAX Technology AB live credentials and enable live Stripe.
Rollback and legacy handling
Do not drop ownership columns to roll back the application. Roll back the application deployment to its prior SHA if needed, retaining the additive columns and snapshot. A paid Stripe event for a legacy unowned order receives 503 and requires an explicit, audited support decision; the webhook does not guess a tenant or acknowledge it as fulfilled. Do not silently backfill ownership from order config, browser storage, or a known order ID.