Sha256: 8a1e4a397e6e391ffcc399aa9f2c71416f470073be637f183982e093b7ee0427

Contents?: true

Size: 543 Bytes

Versions: 16

Compression:

Stored size: 543 Bytes

Contents

class AddAmountCurrency < ActiveRecord::Migration
  def up
    rename_column   :ems_registrations, :amount, :amount_paid_cents
    add_column      :ems_registrations, :amount_paid_currency, :string
    
    Registration.unscoped.all.each do |r|
      Account.current = Account.find(r.account_id)
      r.update_attribute(:amount_paid_currency, r.workshop_price.price_currency)
    end
  end

  def down
    rename_column   :ems_registrations, :amount_paid_cents, :amount
    remove_column   :ems_registrations, :amount_paid_currency
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_event-4.2.3.10 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.9 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.8 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.7 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.6 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.5 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.4 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.3 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.2 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3.1 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.3 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.2.3 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.2.2 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.2.1 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.2 db/migrate/20130624134506_add_amount_currency.rb
dm_event-4.2.1.5 db/migrate/20130624134506_add_amount_currency.rb