Reversible migration in Rails 4
Suppose you want to add an additional function to update all models during the migration. You can do this:
def change
add_column :users, :activity, :datetime
reversible do |direction|
direction.up {
User.update_all(activity: Time.now.utc)
}
end
end
Written by David Paluy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#