fix(recovery): restore source removed by production documentation merge
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user