jeudi 3 février 2022

How can we sync a database schema that is shared between multiple projects repositories?

We have a database schema that multiple projects depend on. These projects are stored on github repositories.

Let's say for example that we have a user schema that is existing at both projects A and B, project A is used by customers and project B is our backoffice for data management:

{
id: string
name: string
}

A dev adds a age property on project A. So the schema becomes

{
id: string
name: string
age: number
}

We are sure that this change must also reflect in project B since we must be able to manage the age of a user in our backoffice, so the dev must also manually copy (commit, push and open a PR) this property into the repo of the project B.

The issue we are having is that when a developer updates the schema on one of the projects, the same changes must reflect on the other repositories also. Manually copying these changes into the other repos can become a hard task.

Can you suggest a way to sync the files between the multiple repositories knowing that these schemas have also dependencies (mainly nested MongoDB schemas) that should be also shared between the other repos?

One of the alternative solutions we thought about are:

  1. Building a microservice for the shared schemas so that every schema and even files related to it can be centralized in a single project
  2. Creating a script that tracks changes on the shared schemas and syncs the repositories but this can be complicated since the script has to detect any dependencies in the shared schemas files

We are open to other suggestions than syncing the files between the repos.

Aucun commentaire:

Enregistrer un commentaire