Our company has broken up most of our large Monolith application into smaller Microservices and we have a clear plan on how to get new services on Kubrenetes into a CI/CD pipeline.

However, we still have some parts of our applications which have not been broken up because of their database dependencies and the fact that they require downtime to deploy because of DB Migration issues. Part of the problem is that we have a large number of stored procedures which contain business logic in them.

I've seen plenty of information about how to refactor code and APIs so that we can have Blue/Green/Canary deployments. But how do we this for DB changes or migrations without downtime?


1 Answer 1


It is quite difficult to migrate the databases without downtime, however, using some approaches you can do it with very minimum impact, nearly a zero downtime.

The main idea in this is to create new databases with new schema. Then make changes in your code. First migrate the data from the old database to the new database. Then make changes in your code such that it starts writing to both the databases, old and new. You need to decide a time (time when there will be least writes to the database). Then stop all the writes. Remove the old database and make sure all the writes should now happen to new database from now on. Then start the writes back.

In this way, you can achieve DB migration with minimal downtime.

You can check this for a detailed information on how this can be done.

  • Thanks. Is this a common practice, and if so, are there libraries which make the pattern of read-failover from the new database easier?
    – avi
    Sep 11, 2019 at 7:29
  • Yes, you can say this is a common practice as this strategy provides very minimal downtime. About libraries, I am not completely sure. You may need to search as per your database requirement.
    – Samit
    Sep 13, 2019 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.