Skip to content

Instantly share code, notes, and snippets.

@CarlosEspejo
Created June 24, 2015 12:52
Add a column to a big table without downtime
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