Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add missing indexes for spree_adjustments
Damian Legawieca2cb294ab990
diff --git a/core/db/migrate/20251222000000_add_performance_indexes_to_spree_adjustments.rb b/core/db/migrate/20251222000000_add_performance_indexes_to_spree_adjustments.rbnew file mode 100644index 0000000000..804062e724--- /dev/null+++ b/core/db/migrate/20251222000000_add_performance_indexes_to_spree_adjustments.rb@@ -0,0 +1,25 @@+class AddPerformanceIndexesToSpreeAdjustments < ActiveRecord::Migration[7.2]+ def change+ # Composite index for filtering adjustments by order, type and eligibility+ # Used in OrderUpdater#update_adjustment_total when summing eligible adjustments+ # and filtering by source_type (e.g., promotion adjustments)+ add_index :spree_adjustments,+ [:order_id, :eligible, :source_type],+ name: 'index_spree_adjustments_on_order_eligible_source_type',+ if_not_exists: true++ # Composite index for AdjustmentsUpdater queries that filter by adjustable and source type+ # Used when recalculating tax and promotion adjustments for a specific adjustable+ add_index :spree_adjustments,+ [:adjustable_type, :adjustable_id, :source_type],+ name: 'index_spree_adjustments_on_adjustable_and_source_type',+ if_not_exists: true++ # Index for state-based filtering (open/closed adjustments)+ # Used in Adjustment.not_finalized and Adjustment.finalized scopes+ add_index :spree_adjustments,+ [:order_id, :state],+ name: 'index_spree_adjustments_on_order_id_and_state',+ if_not_exists: true+ end+end