feat(payments): bind orders to verified tenant and buyer
CI (SIAX Cloud) / integration (push) Has been skipped
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 14s
masterplan-lock / check (pull_request) Successful in 4s
CI (SIAX Cloud) / security (pull_request) Successful in 14s
Security Scan (SIAX Cloud) / security (push) Successful in 30s
CI (SIAX Cloud) / quality (push) Successful in 35s
CI (SIAX Cloud) / integration (pull_request) Successful in 25s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 54s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m31s

This commit is contained in:
2026-09-15 19:53:58 +02:00
parent f976f36530
commit a1557b2a7d
19 changed files with 326 additions and 76 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;