Sha256: b312be2690ce2f799a426279f42225aee78ca0520a3c5d4c5106674de489ddec

Contents?: true

Size: 673 Bytes

Versions: 4

Compression:

Stored size: 673 Bytes

Contents

# This migration comes from spree (originally 20130807024302)
class RenameAdjustmentFields < ActiveRecord::Migration
  def up
    remove_column :spree_adjustments, :originator_id
    remove_column :spree_adjustments, :originator_type

    add_column :spree_adjustments, :order_id, :integer unless column_exists?(:spree_adjustments, :order_id)

    # This enables the Spree::Order#all_adjustments association to work correctly
    Spree::Adjustment.reset_column_information
    Spree::Adjustment.find_each do |adjustment|
      if adjustment.adjustable.is_a?(Spree::Order)
        adjustment.order = adjustment.adjustable
        adjustment.save
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sprangular-0.1.0 spec/dummy/db/migrate/20140814105715_rename_adjustment_fields.spree.rb
sprangular-0.0.1 spec/dummy/db/migrate/20140814105715_rename_adjustment_fields.spree.rb
bcms_spree-0.0.2 test/dummy/db/migrate/20140915222627_rename_adjustment_fields.spree.rb
bcms_spree-0.0.1 test/dummy/db/migrate/20140915222627_rename_adjustment_fields.spree.rb