Sha256: 123e07178f32582df476c7d2fd2d5ea73558bcc8f03cbef9d7568c145a3a496e

Contents?: true

Size: 511 Bytes

Versions: 2

Compression:

Stored size: 511 Bytes

Contents

# This migration comes from spree (originally 20141101231208)
class FixAdjustmentOrderPresence < ActiveRecord::Migration
  def change
    say 'Fixing adjustments without direct order reference'
    Spree::Adjustment.where(order: nil).find_each do |adjustment|
      adjustable = adjustment.adjustable
      if adjustable.is_a? Spree::Order
        adjustment.update_attributes!(order_id: adjustable.id)
      else
        adjustment.update_attributes!(order_id: adjustable.order.id)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_order_reporting-0.0.2 spec/dummy/db/migrate/20160707103540_fix_adjustment_order_presence.spree.rb
spree_order_reporting-0.0.1 spec/dummy/db/migrate/20160706112492_fix_adjustment_order_presence.spree.rb