MongoDb migration frameworks

Roman Mikhailov - May 27 '19 - - Dev Community

What do you do when you need to upgrade/downgrade schema and seed on first install your MongoDB?

I'm looking for opinions, examples, tutorials, and suggestions from the community.

Here's an example of one using node-migrate

https://www.freecodecamp.org/news/how-to-automate-database-migrations-in-mongodb-d6b68efe084e/

Background:

I have a Micro Services (5) application that uses MongoDd. I'd like to allow my services to upgrade their schema in an automated way. In other words, I'd like to avoid running scripts or queries manually. If I have to downgrade a version of a service, it should be able to downgrade the schema as well. It's also possible that a service is scaled horizontally, more than one clone is running. Therefore, this solution must avoid collusion or duplication. Two or more clones should not attempt to apply a migration at the same time.

I'm leaning towards using node-migrate to implement the migration steps. What to do about the control of race conditions is not clear yet for me. I'm thinking about putting the database in read-only mode for the duration of the upgrade. I realized that this last statement does not make sense. I would never roll out all instances at once. It would always be one at a time. Therefore, the first one to get a new version will take care of the upgrade.

. . . . . . . . . .
Terabox Video Player