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 AddStoreIdToSpreeCustomerReturns migration

Szymon Iwacz870c059d4682
diff --git a/core/db/migrate/20210722090705_add_store_id_to_spree_customer_returns.rb b/core/db/migrate/20210722090705_add_store_id_to_spree_customer_returns.rb
index ee89c944c5..b5a9963a75 100644
--- a/core/db/migrate/20210722090705_add_store_id_to_spree_customer_returns.rb
+++ b/core/db/migrate/20210722090705_add_store_id_to_spree_customer_returns.rb
@@ -4,7 +4,8 @@ class AddStoreIdToSpreeCustomerReturns < ActiveRecord::Migration[5.2]
add_column :spree_customer_returns, :store_id, :bigint
add_index :spree_customer_returns, :store_id
Spree::CustomerReturn.reset_column_information
- Spree::CustomerReturn.find_each { |cr| cr.update_column(:store_id, cr.order.store_id) }
+ default_store_id = Spree::Store.default.id
+ Spree::CustomerReturn.find_each { |cr| cr.update_column(:store_id, cr.order&.store_id || default_store_id) }
end
end
end