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
Keep the integrations index migration free of data cleanup
Damian Legawiecdf6033319a82
diff --git a/spree/core/db/migrate/20260806130001_add_unique_store_type_index_to_spree_integrations.rb b/spree/core/db/migrate/20260806130001_add_unique_store_type_index_to_spree_integrations.rbindex 873e5953c0..c6f2a76fea 100644--- a/spree/core/db/migrate/20260806130001_add_unique_store_type_index_to_spree_integrations.rb+++ b/spree/core/db/migrate/20260806130001_add_unique_store_type_index_to_spree_integrations.rb@@ -1,24 +1,9 @@class AddUniqueStoreTypeIndexToSpreeIntegrations < ActiveRecord::Migration[7.2]- def up- # The model has always validated one integration per (store, type), but- # without a backing index a race could have persisted duplicates. Keep the- # oldest of each group so the index can be created.- # Raw SQL, not the model — a migration must not depend on application- # code that may not load at this revision.- execute(<<~SQL)- DELETE FROM spree_integrations- WHERE id NOT IN (- SELECT keeper FROM (- SELECT MIN(id) AS keeper FROM spree_integrations GROUP BY store_id, type- ) AS keepers- )- SQL-+ def change+ # Backs the existing one-integration-per-(store, type) model validation.+ # No de-duplication step: core ships no Integration subclasses and none+ # were creatable before this release, so the table is empty everywhere.add_index :spree_integrations, [:store_id, :type], unique: true,name: 'index_spree_integrations_on_store_id_and_type', if_not_exists: trueend-- def down- remove_index :spree_integrations, name: 'index_spree_integrations_on_store_id_and_type', if_exists: true- endend