In accordance with bounded context, we have identified two microservices implementations, lets call them Service A
and Service B
respectively. Each of these microservices have different repositories (due to the benefits of Single Responsibility and better ownership). Now, each of these repositories use their own database schema (choice made for better separation of persistence and reduced maintenance of DB instances).
Earlier, we extracted the database migrations scripts (for continuous delivery) into a separate single repository (contains scripts for both Service A
and Service B
's schemas) and run them under a single job under CI. Now as we tackle more stories, we have started facing some challenges, some of which are listed below:
- A change to a single schema triggers the build for the whole database and hence the downstream triggering of all the microservices, hence increasing our feedback time
- We are in general failing to achieve
true
continuous delivery, because a schema change also requires a respective change in theService
code and hence cautious efforts are taken to deploy both the PRs - Moreover, there are some common tables like
Users
which needs to be used by both the schemas, which currently are being duplicated across both the schemas.
So my question/doubt is :
- Should we even separate the DB migrations repository according to the schemas, just like the Services.
- Should we even have separate repository for DB migrations scripts ? Should we club them within their respective
Service
repository code ? - Should we extract the common tables further
a level up
and raiseDomain Events
forEventual Consistency
Any pointers/advice would greatly help.Thanks.