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

chore: create indexes on required id columns for v2 application (#9704)

Hrithikeshdab085160114
diff --git a/v2_compatible_migrations/2025-10-07-131000_add_indexes_on_id_columns/down.sql b/v2_compatible_migrations/2025-10-07-131000_add_indexes_on_id_columns/down.sql
new file mode 100644
index 0000000000..fb18e635e2
--- /dev/null
+++ b/v2_compatible_migrations/2025-10-07-131000_add_indexes_on_id_columns/down.sql
@@ -0,0 +1,22 @@
+-- Drop unique indexes on id columns
+-- This will remove the unique indexes created for id column performance optimization and data integrity
+
+-- tracker tables
+DROP INDEX IF EXISTS customers_id_index;
+
+DROP INDEX IF EXISTS payment_intent_id_index;
+
+DROP INDEX IF EXISTS payment_attempt_id_index;
+
+DROP INDEX IF EXISTS payment_methods_id_index;
+
+DROP INDEX IF EXISTS refund_id_index;
+
+-- Accounts tables
+DROP INDEX IF EXISTS business_profile_id_index;
+
+DROP INDEX IF EXISTS merchant_account_id_index;
+
+DROP INDEX IF EXISTS merchant_connector_account_id_index;
+
+DROP INDEX IF EXISTS organization_id_index;
diff --git a/v2_compatible_migrations/2025-10-07-131000_add_indexes_on_id_columns/up.sql b/v2_compatible_migrations/2025-10-07-131000_add_indexes_on_id_columns/up.sql
new file mode 100644
index 0000000000..a8e27af148
--- /dev/null
+++ b/v2_compatible_migrations/2025-10-07-131000_add_indexes_on_id_columns/up.sql
@@ -0,0 +1,21 @@
+-- Create unique indexes on id columns for better query performance and data integrity
+
+-- Tracker Tables
+CREATE UNIQUE INDEX IF NOT EXISTS customers_id_index ON customers (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS payment_intent_id_index ON payment_intent (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS payment_attempt_id_index ON payment_attempt (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS payment_methods_id_index ON payment_methods (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS refund_id_index ON refund (id);
+
+-- Accounts Tables
+CREATE UNIQUE INDEX IF NOT EXISTS business_profile_id_index ON business_profile (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS merchant_account_id_index ON merchant_account (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS merchant_connector_account_id_index ON merchant_connector_account (id);
+
+CREATE UNIQUE INDEX IF NOT EXISTS organization_id_index ON organization (id);