Sha256: 04a91848df3abd667241fe6a3d081490a86695d3df9ad3059fa47a53993eb65d

Contents?: true

Size: 454 Bytes

Versions: 21

Compression:

Stored size: 454 Bytes

Contents

class FixAdjustmentOrderPresence < ActiveRecord::Migration[4.2]
  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

21 entries across 21 versions & 1 rubygems

Version Path
solidus_core-2.3.1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.2.2 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.1.1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.0.3 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.3.0 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.3.0.rc3 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.3.0.rc2 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.3.0.rc1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.3.0.beta1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.0.2 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.2.1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.2.0 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.2.0.rc1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.2.0.beta1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.1.0 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.1.0.rc1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.0.1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.1.0.beta1 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.0.0 db/migrate/20141101231208_fix_adjustment_order_presence.rb
solidus_core-2.0.0.rc1 db/migrate/20141101231208_fix_adjustment_order_presence.rb