From 074018d2a6c52da8255962fc4d7a49e4b352eab6 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 21 Sep 2017 16:59:28 +1000 Subject: [PATCH] Copy and run adjustment states migration from updated version of spree Note: this migration took 28.7571s to run against Aus production data on my local machine --- ...0921065259_update_adjustment_states.spree.rb | 17 +++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170921065259_update_adjustment_states.spree.rb diff --git a/db/migrate/20170921065259_update_adjustment_states.spree.rb b/db/migrate/20170921065259_update_adjustment_states.spree.rb new file mode 100644 index 0000000000..9040709751 --- /dev/null +++ b/db/migrate/20170921065259_update_adjustment_states.spree.rb @@ -0,0 +1,17 @@ +# This migration comes from spree (originally 20130417120035) +class UpdateAdjustmentStates < ActiveRecord::Migration + def up + Spree::Order.complete.find_each do |order| + order.adjustments.update_all(:state => 'closed') + end + + Spree::Shipment.shipped.includes(:adjustment).find_each do |shipment| + shipment.adjustment.update_column(:state, 'finalized') if shipment.adjustment + end + + Spree::Adjustment.where(:state => nil).update_all(:state => 'open') + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 5c70c8e6f9..77459f7d73 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 => 20170512115519) do +ActiveRecord::Schema.define(:version => 20170921065259) do create_table "account_invoices", :force => true do |t| t.integer "user_id", :null => false