1

Simple question, but I can't seem to find an answer.

On a live production site that has active users at all times of the day, what is the best way to migrate the database without going into maintenance mode?

In my situation, I've added a few columns to my database and want to migrate the changes up. Normally, I would simply run heroku maintenance:on, then migrate my changes, then turn maintenance off -- obviously this will avoid any exceptions/errors in between the push and the migration. Now that I consistently have active users, I feel there has to be a way to do this seamlessly -- that is not kicking anyone off and throwing a maintenance screen at them.

Would appreciate any help. Please link any docs if this is talked about somewhere -- seriously can't find anything.

Kathan
  • 1,428
  • 2
  • 15
  • 31
  • 1
    I think what you want is something like this: http://stackoverflow.com/questions/15500530/blue-green-deployment-on-heroku-or-another-cloud-platform-as-a-service – Albin Mar 08 '16 at 07:29

2 Answers2

1

A database migration strategy with zero downtime depends on various factors:

  • Do you want to add, remove or rename a column? Do you need to change a columns type or want to add an index?
  • How big is the table, how long will the migration take?
  • Is the table heavily used or is it possible to disable just this model.
  • What database engine do you use? Some databases lock the whole table even for minor changes.
  • What level of access right does the database user have? Some tools (like Soundcloud's lhm needs more rights than a usual Rails app.

You will find some example how to add or remove columns in this readme.

spickermann
  • 100,941
  • 9
  • 101
  • 131
1

Check out Heroku pre-boot. It may be exactly what you are looking for.

hashrocket
  • 2,210
  • 1
  • 16
  • 25