Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Fix: installed migrations with a number in their name were reported missing

Damian Legawiece12f856baa72
diff --git a/spree/core/lib/spree/migrations.rb b/spree/core/lib/spree/migrations.rb
index 2a1a67cd59..50c5805a12 100644
--- a/spree/core/lib/spree/migrations.rb
+++ b/spree/core/lib/spree/migrations.rb
@@ -29,8 +29,11 @@ module Spree
name
end.compact
+ installed = engine_in_app.map(&:camelize).to_set
- missing_migrations = engine_migrations.sort - engine_in_app.sort
+ # Compared by class name: installing a migration writes its file name
+ # back from the class, so `decimal_19_4` is installed as `decimal194`.
+ missing_migrations = engine_migrations.sort.reject { |name| installed.include?(name.camelize) }
unless missing_migrations.empty?
puts "[#{engine_name.capitalize} WARNING] Missing migrations."
missing_migrations.each do |migration|
diff --git a/spree/core/spec/lib/spree/migrations_spec.rb b/spree/core/spec/lib/spree/migrations_spec.rb
index 9ef268ca0c..28e9f5d49c 100644
--- a/spree/core/spec/lib/spree/migrations_spec.rb
+++ b/spree/core/spec/lib/spree/migrations_spec.rb
@@ -25,6 +25,15 @@ module Spree
end
end
+ # Installing writes the file name back from the class name, which drops
+ # the underscore before a number.
+ it 'recognizes a migration whose installed name lost an underscore before a number' do
+ expect(Dir).to receive(:entries).with(engine_dir).and_return(['.', '20261009000001_change_columns_to_decimal_19_4.rb'])
+ expect(Dir).to receive(:entries).with(app_dir).and_return(['.', '20261009065323_change_columns_to_decimal194.spree.rb'])
+
+ expect(subject.check).to be_nil
+ end
+
context 'no missing migrations' do
it 'says nothing' do
expect(Dir).to receive(:entries).with(engine_dir).and_return engine_migrations