https://github.com/soundcloud/lhm
I've used it in the past a lot. You have to make sure to throttle the migration, or else it'll max out your CPU & memory.
https://github.com/soundcloud/lhm
I've used it in the past a lot. You have to make sure to throttle the migration, or else it'll max out your CPU & memory.
1) Write code that works with current and new schema
2) Deploy that code
3) Run that version for long enough to know you will not roll it back
3) Run the migration, moving the db from current to new schema
4) Clean up code to only work with new schema
5) Deploy that code
Where step 3 uses an appropriate tool for online schema changes for your database.
Here a some writeups of that approach I found when trying to explain this to a friend who's a rails developer:
* http://blog.honeybadger.io/zero-downtime-migrations-of-large...
* https://pedro.herokuapp.com/past/2011/7/13/rails_migrations_...
* https://www.rainforestqa.com/blog/2014-06-27-zero-downtime-d...
* https://blog.engineyard.com/2011/zero-downtime-deploys-with-...
Its main advantage seems to be that it doesn't require triggers on the original table (it works by subscribing to the replication log), thus not making write locks worse during the migration.
I haven't tried either yet, so if anybody has some experience with them, do please share a comparison!
It has a nice webapp to monitor and run schema migrations, including peer review. I use it all the time at Square, and it's pretty great.
Disclaimer: I worked on LHM a few years ago, still one of my favorite projects :)