Last active
July 21, 2020 01:43
-
-
Save Kalimaha/45f970a0b435d00176ca645078ff5b02 to your computer and use it in GitHub Desktop.
Zero downtime migration
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
################################################################################ | |
# Please Note: this version requires https://github.com/khiav223577/in_batches # | |
################################################################################ | |
class AddLifecycleWebPushPermittedToUsers < ActiveRecord::Migration | |
disable_ddl_transaction! | |
def up | |
ActiveRecord::Base.transaction do | |
add_column :users, :lifecycle_web_push_permitted, :boolean, default: nil | |
execute('ALTER TABLE users ALTER COLUMN lifecycle_web_push_permitted SET DEFAULT false') | |
end | |
User.unscoped.in_batches.update_all(lifecycle_web_push_permitted: false) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment