# 0pt order-ownership cutover Status: source implementation in PR #66; **not applied to production**. Canonical design: [ADR-001](./ADR-001-order-ownership.md). ## Dependency order 1. Confirm the target Postgres is the canonical 0pt order store. Capture a recoverable database snapshot and identify current migration state. `sql/001_init.sql` and `sql/006_orders_idempotency.sql` must already be present; this repository has no general automated migration runner yet. 2. Apply `sql/011_orders_tenant_ownership.sql` transactionally to staging, then production only after staging verification. The file is idempotent and leaves legacy NULL-owned rows untouched. For an environment where `DATABASE_URL` is securely injected, a manual controlled step is: ```bash psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f sql/011_orders_tenant_ownership.sql ``` 3. Verify `orders.tenant_id`, `orders.buyer_subject`, the ownership-pair check constraint and `orders_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. 4. 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. 5. 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.