Skip to content

Instantly share code, notes, and snippets.

@tony612
Created August 27, 2013 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony612/6350745 to your computer and use it in GitHub Desktop.
Save tony612/6350745 to your computer and use it in GitHub Desktop.
use Model.reset_column_information to let the modification work, and use say_with_time to explain the action..
class AddAddressToEvent < ActiveRecord::Migration
def up
add_column :events, :address, :string, :after => :lat
Event.reset_column_information
say_with_time "Update each event, which will result in all events to update their address" do
Event.find_each { |event| event.save! }
end
end
def down
remove_column :events, :address
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment