BEGIN;

-- Only safe to restore if every existing row's payment_id is still a valid
-- payments(id) - true as long as no AI_CREDIT_PURCHASE invoices exist yet.
ALTER TABLE invoices ADD CONSTRAINT invoices_payment_id_fkey FOREIGN KEY (payment_id) REFERENCES payments(id);

COMMIT;
