Created
October 26, 2011 20:25
-
-
Save JEG2/1317705 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleMigration < ActiveRecord::Migration | |
class MyModel < ActiveRecord::Base | |
def some_method_i_need | |
# ... | |
end | |
end | |
def self.up | |
add_column :my_models, :whatever, :string | |
MyModel.find_each do |my_model| | |
my_model.whatever = my_model.some_method_i_need | |
my_model.save! | |
end | |
end | |
def self.down | |
remove_column :my_models, :whatever | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment