Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(refunds): add missing indexes (#14454)

Kashif926d41f45af8
diff --git a/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/down.sql b/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/down.sql
new file mode 100644
index 0000000000..8141cf2e00
--- /dev/null
+++ b/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX CONCURRENTLY IF EXISTS refund_processor_merchant_id_connector_refund_id_index;
diff --git a/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/metadata.toml b/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/metadata.toml
new file mode 100644
index 0000000000..79e9221c1f
--- /dev/null
+++ b/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/metadata.toml
@@ -0,0 +1 @@
+run_in_transaction = false
diff --git a/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/up.sql b/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/up.sql
new file mode 100644
index 0000000000..7e7d2b4b83
--- /dev/null
+++ b/migrations/2026-09-27-150000_add_index_processor_merchant_id_connector_refund_id_for_refund/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+CREATE INDEX CONCURRENTLY IF NOT EXISTS refund_processor_merchant_id_connector_refund_id_index ON refund (processor_merchant_id, connector_refund_id);
diff --git a/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/down.sql b/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/down.sql
new file mode 100644
index 0000000000..4438f17c08
--- /dev/null
+++ b/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX CONCURRENTLY IF EXISTS refund_merchant_id_connector_refund_id_index;
diff --git a/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/metadata.toml b/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/metadata.toml
new file mode 100644
index 0000000000..79e9221c1f
--- /dev/null
+++ b/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/metadata.toml
@@ -0,0 +1 @@
+run_in_transaction = false
diff --git a/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/up.sql b/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/up.sql
new file mode 100644
index 0000000000..1fdadd753f
--- /dev/null
+++ b/migrations/2026-09-27-150001_add_index_merchant_id_connector_refund_id_for_refund/up.sql
@@ -0,0 +1,4 @@
+-- Your SQL goes here
+-- Supports the stagger-release fallback lookup by merchant_id (for refunds with NULL processor_merchant_id).
+-- TODO: Drop this index once processor_merchant_id is backfilled and the merchant_id fallback is removed.
+CREATE INDEX CONCURRENTLY IF NOT EXISTS refund_merchant_id_connector_refund_id_index ON refund (merchant_id, connector_refund_id);