Zero downtime migrations with ActiveRecord 3+ and PostgreSQL
Zero downtime migrations with ActiveRecord 3+ and PostgreSQL
Zero downtime migrations with ActiveRecord 3+ and PostgreSQL.
Catch problematic migrations at development/test time! Heavily inspired by these similar projects:
Simply add this gem to the project Gemfile.
gem "zero_downtime_migrations"This gem will automatically raise exceptions when potential database locking migrations are detected.
It checks for common things like:
each instead of find_each to loop thru ActiveRecord objectsThese exceptions display clear instructions of how to perform the same operation the "zero downtime way".
This can take a long time with significant database size or traffic and lock your table!
class AddPublishedToPosts = ?", 1.day.ago).update_all(published: true)
end
endEnforcements can be globally disabled by setting ENV["SAFETY_ASSURED"] when running migrations.
SAFETY_ASSURED=1 bundle exec rake db:migrate --traceThese enforcements are automatically disabled by default for the following scenarios:
rake db:schema:load instead of db:migrateRollupMigrationsbundle exec rspecMIT - Copyright © 2016 LendingHome
No open issues yet, or sync has not completed.