mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add migration to set default stock location on all shipments without stock location
This is a modified version of this spree migration: https://github.com/spree/spree/commit/219e09b
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
class SetDefaultStockLocationOnShipments < ActiveRecord::Migration
|
||||
def up
|
||||
if Spree::Shipment.where('stock_location_id IS NULL').count > 0
|
||||
location = DefaultStockLocation.find_or_create
|
||||
Spree::Shipment.where('stock_location_id IS NULL').update_all(stock_location_id: location.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user