mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Add migration to create default shipping category and set it in shipping methods and products that do not have a shipping category yet
This is a modified version of this spree migration: af16cf1d74
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
class AddShippingCategoryToShippingMethodsAndProducts < ActiveRecord::Migration
|
||||
def up
|
||||
# This is different from the equivalent Spree migration
|
||||
# Here we are creating the default shipping category even if there are already shipping categories
|
||||
default_category = Spree::ShippingCategory.create!(name: "Default")
|
||||
|
||||
Spree::ShippingMethod.all.each do |method|
|
||||
method.shipping_categories << default_category if method.shipping_categories.blank?
|
||||
end
|
||||
|
||||
Spree::Product.where(shipping_category_id: nil).update_all(shipping_category_id: default_category.id)
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20190221214542) do
|
||||
ActiveRecord::Schema.define(:version => 20190313142540) do
|
||||
|
||||
create_table "account_invoices", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
||||
Reference in New Issue
Block a user