Sha256: 115762cbc9c88c649f88b79a040529134e9cc067835b26c2b46f443fd30d8880

Contents?: true

Size: 611 Bytes

Versions: 7

Compression:

Stored size: 611 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
spree_core-2.3.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-2.2.4 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-2.2.3 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-2.3.0 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-2.2.2 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-2.2.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-2.2.0 db/migrate/20130807024302_rename_adjustment_fields.rb