From c39bd6b59d7911ef4b8158252d7a635ff6e24736 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 14 Aug 2013 11:27:16 +1000 Subject: [PATCH] Remove shipping methods with the now-absent itemwise calculator --- ..._shipping_methods_using_itemwise_calculator.rb | 15 +++++++++++++++ db/schema.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb diff --git a/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb b/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb new file mode 100644 index 0000000000..e019ac3fe5 --- /dev/null +++ b/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb @@ -0,0 +1,15 @@ +class RemoveShippingMethodsUsingItemwiseCalculator < ActiveRecord::Migration + class OpenFoodWeb::Calculator::Itemwise < Spree::Calculator; end + + def up + Spree::ShippingMethod.all.select { |sm| sm.calculator.type == 'OpenFoodWeb::Calculator::Itemwise' }.each do |sm| + + say "Destroying itemwise shipping method with id #{sm.id}" + sm.destroy + end + end + + def down + Spree::ShippingMethod.create!({name: 'Delivery', zone: Spree::Zone.last, calculator: OpenFoodWeb::Calculator::Itemwise.new}, without_protection: true) + end +end diff --git a/db/schema.rb b/db/schema.rb index d9eff970c6..dbedb06f59 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130812233634) do +ActiveRecord::Schema.define(:version => 20130814010857) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id"