Sha256: 4059a720192acf2258d37daefc6d1890b8e9a0b428415eebcbaa629af8aa9a4b

Contents?: true

Size: 564 Bytes

Versions: 9

Compression:

Stored size: 564 Bytes

Contents

# This migration comes from spree (originally 20130830001033)
class AddShippingCategoryToShippingMethodsAndProducts < ActiveRecord::Migration[4.2]
  def up
    default_category = Spree::ShippingCategory.first
    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

  def down
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
spree_purchase_order-3.7.0 spec/dummy/db/migrate/20191113195804_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_billing_sisow-0.9.2 spec/dummy/db/migrate/20190729091745_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_billing_sisow-0.9.1 spec/dummy/db/migrate/20190729091745_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_purchase_order-3.6.0 spec/dummy/db/migrate/20180516181933_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_purchase_order-3.5.0 spec/dummy/db/migrate/20180516181933_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_purchase_order-3.5.0.rc1 spec/dummy/db/migrate/20180516181933_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_purchase_order-3.4.0 spec/dummy/db/migrate/20180516181933_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_purchase_order-3.3.0 spec/dummy/db/migrate/20180516181933_add_shipping_category_to_shipping_methods_and_products.spree.rb
spree_purchase_order-3.2.0 spec/dummy/db/migrate/20180516181933_add_shipping_category_to_shipping_methods_and_products.spree.rb