It’s a Load Alright

class MoveCustomersToStopThru < ActiveRecord::Migration
  def self.up
    Load.class_eval do
      has_and_belongs_to_many :customers
    end

    add_column :loads, :customer_id, :integer
    add_column :loads, :stop_thru_id, :integer

    Load.all.each do |load|
      cs = load.customers
      load.customer = cs[0]
      load.stop_thru = cs[1]
      load.save
    end

    change_column :loads, :customer_id, :integer, :null => false
    drop_table :customers_loads
  end

  def self.down
  end
end

Got a WTF you want to report? Email us.