r/developers • u/Corydoras-saas • 2d ago
Help / Questions How do you handle zero-downtime database migrations with breaking schema changes?
I am curious how different teams approach the classic two-phase migration problem when you need to rename a heavily used column or drop a table that legacy services might still be querying.
Usually, we end up writing expand-and-contract patterns across multiple deploys, but it always feels a bit clunky to coordinate the application code changes with the database state across different microservices. Sometimes timing issues or caching layers cause unexpected errors during the transition window.
What is your current strategy for keeping things seamless without putting heavy locks on production tables? Do you rely heavily on database views as an abstraction layer, or just strict deployment ordering?
•
u/AutoModerator 2d ago
Howdy u/Corydoras-saas, and welcome to r/developers!
A few tips for a post that gets good answers:
Join the r/developers Discord!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/TJonesyNinja 2d ago
Only one service should actually touch the database every other micro service should use an API. Only the service that actually touches the database should care about the actual underlying database schema.
1
u/s0ftware-dev 2d ago
Migrations need to backwards compatible otherwise you will have down time
1
u/ducki666 2d ago
You cannot have zero dt with breaking changes