holman / ama

Ask @holman anything!
732 stars 278 forks source link

How to manage databases while doing rollbacks? #767

Closed harshil93 closed 8 years ago

harshil93 commented 8 years ago

Many a time the new code introduces a new column in a table and this column starts getting filled with data as soon as the code hits production. I can understand doing a rollback of the web tier but then how would the old web tier talk with the new data teir. Are there any established rules on doing db rollbacks for a service which is getting used while getting updated.

harshil93 commented 8 years ago

https://github.com/holman/ama/issues/765

Almost got my answer.

holman commented 8 years ago

Yeah, #765 is pretty close.

Are there any established rules on doing db rollbacks for a service which is getting used while getting updated.

It depends on the database, but in MySQL, for example, lhm will let you migrate a table without downtime.

I think the real answer is that you should really avoid this as much as possible, ha. You don't want to be in a position where the only way to go forward is to rollback both the code and the data layer. Ideally you should have both the new code and the old code be capable of talking to both, and if there's anything serious that comes up during the migration it should hopefully become apparent prior to the switchover and prior to it becoming user-facing.