Learn how I setup database Migration using Sequelize in Microservice Architecture. I am having a conversation with Joe regarding setting up a migration script repository for microservice-based architecture. Creating we go through the step-by-step guide from scratch, let’s have a high-level overview of what we will be having.
Once upon a time, I am having a conversation with Joe regarding setting up a migration script repository for microservice-based architecture. Here is how the conversation goes:
Me: Hey Joe, we’re using Sequelize in our code. But how about our migration? Since we’re using microservice-based architecture if we write our migration file in each service, wouldn’t it hard to manage, and the scripts are scattered everywhere.
Joe: Erm… You probably right. How about we set up a repository called migrations. Where we will centralize all the migration scripts in that repo. So we could have an overview of all the changes in a single repository. What do you think?
Me: That sounds like a good idea. Let’s start looking & work this out.
Before we go through the step-by-step guide from scratch, let’s have a high-level overview of what we will be having.
modelsfolder which contains all the model to the table. We shall always have the latest model structure here so the whole team will check on the repository for the latest table structure.
migrationsfolder which contains all the migration script generated using
sequelize-cliand the changes to the database which coded by the developers.
Without further ado, let’s start dive into the details.