A cli tool to manage mongration migrations
Usage: mongration [options]
Options:
-h, --help output usage information
-f, --folder [value] migrations folder (current dir is default)
-h, --hosts [value] mongoDB hosts
-d, --database [value] mongoDB database
-u, --user [value] mongoDB user
-p, --password [value] mongoDB password
-m, --migration-collection [value] collection to save migrations state
-c, --config [value] path to config file
You can install it as a global package:
npm install -g mongration
Then, you will be able to run mongration as a command.
To check the options, just type:
mongration --help
To avoid installing it globally, you can make use of package.json
scripts
configuration, simply adding mongration
to it.
Example:
{
"scripts": {
"migrate": "mongration -f ./migrations -c cfg.js"
}
}
It will read all migration files (-f
option), ordered by file name, and will
execute the migrations.
Important: when using this tool, you must specify the order by yourself (i.e, 001-first.js, 002-second.js
).
So, a naming standard must be used to set the correct execution order.
You can always use it programmaticaly, to guarantee an specific order.