Created
February 7, 2018 16:42
-
-
Save ccyrille/22468e003dc87d7408a6ed61a6b83200 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 PopulateUsersNewColumnDefaultValue < ActiveRecord::Migration | |
disable_ddl_transaction! | |
def up | |
User.find_in_batches do |users| | |
User.where(id: users.map(&:id), new_column: nil) | |
.update_all(new_column: "default_value") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment