cirandas.net

ref: master

db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
class MoveContactEmailToNoreplyEmailAtEnvironment < ActiveRecord::Migration
  def self.up
    add_column :environments, :noreply_email, :string
    Environment.reset_column_information

    Environment.find_each do |environment|
      environment.noreply_email = environment.contact_email
      environment.contact_email = nil
      environment.save!
    end
  end

  def self.down
    say "this migration can't be reverted"
  end
end