8 lines
579 B
SQL
8 lines
579 B
SQL
-- A new missing record is not evidence of collection. Historical rows/snapshots remain intact.
|
|
INSERT INTO "KybChecklistItem" ("id", "merchantId", "documentCode", "state", "updatedAt")
|
|
SELECT gen_random_uuid()::text, "id", 'AUTHORIZED_REPRESENTATIVE', 'MISSING', CURRENT_TIMESTAMP
|
|
FROM "Merchant" WHERE "status" NOT IN ('LIVE', 'REJECTED')
|
|
ON CONFLICT ("merchantId", "documentCode") DO NOTHING;
|
|
-- Invalidate any editor opened against the old policy; preserve company/stage timestamps.
|
|
UPDATE "Merchant" SET "version" = "version" + 1 WHERE "status" NOT IN ('LIVE', 'REJECTED');
|