-- =====================================================================
-- 002 — index for the stale-payment sweep (modules/payments/payments.worker.ts)
--
-- Every minute the worker looks for in-flight payments (status pending/processing) older than
-- 20 minutes across ALL restaurants. idx_payments_restaurant leads with restaurant_id, so without
-- this index that query scans the whole payments table.
-- =====================================================================

ALTER TABLE payments ADD INDEX idx_payments_status_created (status, created_at);
