Managing multiple databases migrations with Alembic

Anand Tripathi
Pythonistas
Published in
10 min readAug 13, 2022

--

Photo by Maksim Shutov on Unsplash

Coming from a background in ORM and python, I loved working with SQLAlchemy as it makes our life so much easier that we don’t have to overthink whether we are using PostgresSQL, MySQL or any other database engine. Alembic just adds more spice to our tech stack when it comes to a migrate your database from one state to another without writing the raw queries. So basically my world was like a fair “PythonyTale”, I meant fairytale.

Everything was going smooth like a JSON object. But then we thought to convert our project from a monolithic app to micro-services.

Photo by Zoran Borojevic on Unsplash

Now comes the twist in architecture. Generally, if you want to convert a project into a microservice then the first thing you have to think for the candidates that can move out and acts as microservices. Microservices will have their own resources, backing services, environment basically everything. So we thought first it would be easy to separate out databases and then move out the resource layer from the project.

So we have to separate our database into smaller independent DBS and as we were following rolling updates so we shipped different DBS to production and in the next release…

--

--