fix(recovery): restore source removed by production documentation merge

This commit is contained in:
2026-11-10 03:42:10 +01:00
parent 585bdd4b44
commit 3d2fc6f913
957 changed files with 115754 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
-- 0pt payment-order ownership, ADR-001.
-- Apply after 001_init.sql and before deploying tenant-scoped order routes.
-- Legacy orders remain NULL-owned and cannot be read or paid by a buyer API.
-- Do not backfill from client-supplied config or guessed order IDs.
ALTER TABLE orders ADD COLUMN IF NOT EXISTS tenant_id text;
ALTER TABLE orders ADD COLUMN IF NOT EXISTS buyer_subject text;
ALTER TABLE orders DROP CONSTRAINT IF EXISTS orders_ownership_pair_ck;
ALTER TABLE orders ADD CONSTRAINT orders_ownership_pair_ck
CHECK ((tenant_id IS NULL AND buyer_subject IS NULL)
OR (tenant_id IS NOT NULL AND length(tenant_id) > 0
AND buyer_subject IS NOT NULL AND length(buyer_subject) > 0));
CREATE INDEX IF NOT EXISTS orders_tenant_created_idx
ON orders (tenant_id, created_at DESC)
WHERE tenant_id IS NOT NULL;