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
Fix: Added checkout zones migration to the 6.0 upgrade (#14791)
Damian Legawiecd01e8d68eb17
diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdxindex 48d41dcd05..d70c94882f 100644--- a/docs/developer/upgrades/5.6-to-6.0.mdx+++ b/docs/developer/upgrades/5.6-to-6.0.mdx@@ -135,10 +135,11 @@ bundle exec rake spree:backfill_order_coupon_codes### Markets on orders```bash+bundle exec rake spree:markets:migrate_checkout_zonesbundle exec rake spree:backfill_order_markets```-Orders missing a market get the store default — `market` is required on carts and orders in 6.0.+A store without a market gets a default one covering its old checkout zone's countries (or its default country), and the checkout zone is cleared. Orders missing a market then get the store default — `market` is required on carts and orders in 6.0.### Fill in the stock level countersdiff --git a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.ymlindex 140fa4d67c..fd369be22f 100644--- a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml+++ b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml@@ -288,6 +288,20 @@ steps:with one statement scoped to the rows still missing a code, so aninterrupted run picks up where it stopped.+ - id: migrate_checkout_zones+ name: "Convert checkout zones to markets"+ task: "spree:markets:migrate_checkout_zones"+ notes: |+ Markets replace the store's checkout zone in Spree 6. Stores that have+ no market yet get a default one covering their checkout zone's+ countries, or their default country when no zone was set, and the+ checkout zone is cleared.++ Run before migrate_tax_zones, which matches zone price rules against a+ store's markets, and before backfill_order_markets, which assigns each+ store's default market to its orders. Idempotent: stores that already+ have a market are skipped.+- id: migrate_promotion_option_value_rulesname: "Rewrite Option Value promotion rules to stable option value ids"task: "spree:upgrade:migrate_promotion_option_value_rules"diff --git a/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb b/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rbindex a735e54e67..ad51eab0b5 100644--- a/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb+++ b/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb@@ -14,6 +14,7 @@ describe '6.0 data migration tasks' doload Spree::Core::Engine.root.join('lib', 'tasks', 'fulfillment_statuses_migration.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'deliveries_migration.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'tax_zones_migration.rake')+ load Spree::Core::Engine.root.join('lib', 'tasks', 'markets.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'capture_methods_migration.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'typed_stock_movements_migration.rake')end@@ -530,6 +531,31 @@ describe '6.0 data migration tasks' doendend+ describe 'spree:markets:migrate_checkout_zones' do+ let(:legacy_store) { create(:store) }+ let(:zone) { create(:zone, name: 'Checkout Zone', kind: 'country') }++ before do+ legacy_zone_member(zone, Spree::Country.by_iso('DE'))+ legacy_zone_member(zone, Spree::Country.by_iso('FR'))+ legacy_store.markets.delete_all+ legacy_store.update_column(:checkout_zone_id, zone.id)+ end++ it 'turns the checkout zone into a default market once' do+ expect do+ run_task('spree:markets:migrate_checkout_zones')+ run_task('spree:markets:migrate_checkout_zones')+ end.to change { legacy_store.markets.count }.from(0).to(1)++ legacy_store.reload+ market = legacy_store.markets.first+ expect(market).to be_default+ expect(market.country_codes).to eq(%w[DE FR])+ expect(legacy_store.read_attribute(:checkout_zone_id)).to be_nil+ end+ end+describe 'spree:backfill_order_markets' doit 'assigns the store default market to orders missing one' doorder = create(:order, store: store)