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(customer): change `customers_id_index` from unique to non-unique to support V1 customer backfill (#11750)

Shankar Singh Cd4c03b55d1e4
diff --git a/v2_compatible_migrations/2026-04-07-000001_make_customers_id_index_non_unique/down.sql b/v2_compatible_migrations/2026-04-07-000001_make_customers_id_index_non_unique/down.sql
new file mode 100644
index 0000000000..9068177939
--- /dev/null
+++ b/v2_compatible_migrations/2026-04-07-000001_make_customers_id_index_non_unique/down.sql
@@ -0,0 +1,4 @@
+-- Revert to unique index (rollback)
+-- Note: This will fail if there are duplicate id values in the customers table.
+DROP INDEX IF EXISTS customers_id_index;
+CREATE UNIQUE INDEX IF NOT EXISTS customers_id_index ON customers (id);
diff --git a/v2_compatible_migrations/2026-04-07-000001_make_customers_id_index_non_unique/up.sql b/v2_compatible_migrations/2026-04-07-000001_make_customers_id_index_non_unique/up.sql
new file mode 100644
index 0000000000..205be79b0e
--- /dev/null
+++ b/v2_compatible_migrations/2026-04-07-000001_make_customers_id_index_non_unique/up.sql
@@ -0,0 +1,7 @@
+-- Replace the unique index on customers(id) with a non-unique index.
+-- This allows the backfill migration to populate id from customer_id
+-- even when there are duplicate customer_id values in the database.
+-- Required because v1 used composite PK (merchant_id, customer_id),
+-- so duplicate customer_id values exist across different merchants.
+DROP INDEX IF EXISTS customers_id_index;
+CREATE INDEX IF NOT EXISTS customers_id_index ON customers (id);