Sha256: 85b8177679bc468d991e89a4f9ded5bce035aff224d07dfd1fe0373839fe0bb2

Contents?: true

Size: 865 Bytes

Versions: 107

Compression:

Stored size: 865 Bytes

Contents

class RenameAdjustmentFields < ActiveRecord::Migration[4.2]
  def up
    # Add Temporary index
    add_index :spree_adjustments, :adjustable_type unless index_exists?(:spree_adjustments, :adjustable_type)

    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.where(adjustable_type: "Spree::Order").find_each do |adjustment|
      adjustment.update_column(:order_id, adjustment.adjustable_id)
    end

    # Remove Temporary index
    remove_index :spree_adjustments, :adjustable_type if index_exists?(:spree_adjustments, :adjustable_type)
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
spree_core-4.0.9 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.1.15 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.2.7 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.3 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.2.6 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.2 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.0 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.0.rc3 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.0.rc2 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.3.0.rc1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.2.5 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.1.14 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.0.8 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.2.4 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-3.7.14.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.2.3.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.1.13.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.0.7.1 db/migrate/20130807024302_rename_adjustment_fields.rb
spree_core-4.2.3 db/migrate/20130807024302_rename_adjustment_fields.rb