Created
June 24, 2015 12:52
Add a column to a big table without downtime
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
disable_ddl_transaction! | |
def up | |
add_column :users, :processed, :boolean | |
change_column :users, :processed, :boolean, default: false | |
execute 'update users set processed = false where processed is null' | |
add_index :users, :processed, where: 'processed = false', algorithm: :concurrently | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment