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
This commit is contained in:
Rob Harrington
2017-09-21 16:59:28 +10:00
parent 386972db3b
commit 074018d2a6
2 changed files with 18 additions and 1 deletions

View File

@@ -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

View File

@@ -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