fix: make Stripe invoice webhooks monotonic
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
237899745
2026-07-26 04:53:21 +08:00
parent 3aefacec6b
commit 037e83e92f
5 changed files with 620 additions and 136 deletions

View File

@@ -0,0 +1,16 @@
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM invoices
WHERE provider_invoice_id IS NOT NULL
GROUP BY provider, provider_invoice_id
HAVING COUNT(*) > 1
) THEN
RAISE EXCEPTION 'duplicate invoices(provider, provider_invoice_id) values require reconciliation before migration 019';
END IF;
END $$;
CREATE UNIQUE INDEX IF NOT EXISTS idx_invoices_provider_object_unique
ON invoices(provider, provider_invoice_id)
WHERE provider_invoice_id IS NOT NULL;