{"repo":"seppevs/migrate-mongo","free":true,"listed":false,"github":"https://github.com/seppevs/migrate-mongo","clone":"git clone https://github.com/seppevs/migrate-mongo.git","description":"A database migration tool for MongoDB in Node","language":"JavaScript","stars":1029,"topics":["mongodb","database-migrations","database","migrations","migrate","mongo","node","npm"],"license":"MIT","category":"databases-storage","readme_excerpt":"migrate-mongo is a database migration tool for MongoDB running in Node.js Requirements - Node.js =20.0.0 - MongoDB 4.x, 5.x, 6.x, or 7.x Installation CLI Usage Basic Usage Initialize a new project Make sure you have Node.js 20 (or higher) installed. Create a directory where you want to store your migrations for your mongo database (eg. 'albums' here) and cd into it Initialize a new migrate-mongo project By default, this creates a CommonJS project. To use ES modules instead: The above command did two things: 1. create a sample 'migrate-mongo-config.js' file and 2. create a 'migrations' directory Edit the migrate-mongo-config.js file. An object or promise can be returned. Make sure you change the mongodb url: Alternatively, you can also encode your database name in the url (and leave out the databaseName property): Creating a new migration script To create a new database migration script, just run the command (Make sure you are in the same directory as the migrations folder. albums here). For example: A new migration file is created in the 'migrations' directory: Edit this content so it actually performs changes to your database. Don't forget to write the down part as well. The object contains the official MongoDB db object The object is a MongoClient instance (which you can omit if you don't use it). There are 2 ways to implement the up and down functions of your migration: 1. Return a Promise 2. Use async-await (recommended) Always make sure the implementation matches the fun","default_branch":null,"files":null,"tree":[],"storefront":"/r/seppevs","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/seppevs/migrate-mongo/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}