Sha256: 64dc55fb90c7941169c55b0cf6d8ae6e3a844caf20cc8396197d4cd6c7d9f6ba

Contents?: true

Size: 927 Bytes

Versions: 3

Compression:

Stored size: 927 Bytes

Contents

# This migration comes from spree (originally 20130807024302)
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

3 entries across 3 versions & 2 rubygems

Version Path
spree_purchase_order-3.7.0 spec/dummy/db/migrate/20191113195794_rename_adjustment_fields.spree.rb
spree_billing_sisow-0.9.2 spec/dummy/db/migrate/20190729091735_rename_adjustment_fields.spree.rb
spree_billing_sisow-0.9.1 spec/dummy/db/migrate/20190729091735_rename_adjustment_fields.spree.rb