command | options | parameters | description | example |
---|---|---|---|---|
help | prints help menu | migrate-consul help | ||
version | prints version | migrate-consul version | ||
init | --help --debug |
[path] [migrationsDirName] | initializes migrations environment -prints help menu -prints verbose debug information |
see #init |
create | --help --path --configPath --key --value --includeExamples --import --recurse --token --debug |
creates a new migration script -prints help menu -path to directory with migrations folder -path to directory with config file -key to auto-fill in migration -value to auto-fill in migration -print examples in migration script -import value from existing consul key -recursively create migrations from existing consul keys -an ACL token (if not in config) -prints verbose debug information |
see #create | |
stage | --help --path --configPath --author --debug |
stages new migrations for deploy -prints help menu -path to directory with migrations folder -path to directory with config file -the author of the script -prints verbose debug information |
migrate-consul stage --author me | |
up | --help --path --configPath --force --token --debug |
runs the up script on all pending migrations -prints help menu -path to directory with migrations folder -path to directory with config file -force script to run even if hash doesn't match -an ACL token (if not in config) -prints verbose debug information |
migrate-consul up | |
down | --help --path --configPath --last [n] --force --token --debug |
runs the down script on the last n migrations -prints help menu -path to directory with migrations folder -path to directory with config file -rollback last n migrations, default 1 -force script to run even if hash doesn't match -an ACL token (if not in config) -prints verbose debug information |
migrate-consul down | |
unstage | --help --path --configPath --failed --pending --author --debug |
unstages migrations -prints help menu -path to directory with migrations folder -path to directory with config file -unstages all failed migrations -unstages all pending migrations -unstages all migrations from author (non-completed) -prints verbose debug information |
migrate-consul unstage --pending migrate-consul unstage --failed |
|
status | --help --path --configPath --debug |
prints the status of all migrations -prints help menu -path to directory with migrations folder -path to directory with config file -prints verbose debug information |
migrate-consul status | |
verify | --help --path --configPath --diff [type] --token --debug |
[type] | verifies up (default) or down scripts -prints help menu -path to directory with migrations folder -path to directory with config file -diff the current value in consul and print output -token an ACL token (if not in config) -prints verbose debug information |
migrate-consul verify --diff migrate-consul verify down |
backup | --help --path --configPath --token --debug |
[..keys] | takes a backup from consul of provided keys -prints help menu -path to directory with migrations folder -path to directory with config file -an ACL token (if not in config) -prints verbose debug information |
migrate-consul backup my/key |
restore | --help --path --configPath --date --list --last --token --debug |
[key] | restores backup to consul of provided key -prints help menu -path to directory with migrations folder -path to directory with config file -restore the key to this date -list backups for key -restore most recent backup -an ACL token (if not in config) -prints verbose debug information |
migrate-consul restore my/key --last |
These options are available on all commands
Each command prints a sub-menu of options for the command with examples
Path to directory containing the migrations folders. Used when executing from a different location such as in certain CD/CI flows
Path to directory containing the migrate-consul-config.jsonc file. Useful when deploying to multiple environments
Prints verbose debug information and passes a debug logger parameter to the scripts for logging inside your scripts
Prints main help menu
migrate-consul version 3.0.7
version (v) Output the version number
backup (b) backs up the consul value of the provided key
create (c) creates a new migration file in the migrations directory
down (d) runs the down migration for the last n completed migrations
init (i) Creates migration config file and migrations directory with a sample migration
restore (r) restores the consul value from the backup of the provided key
stage (s) stages the migrations for deployment
status (stat) print status of migrations
unstage (un) removes the migrations from deployment
up (u) runs the up migration for all staged migrations
verify (ve) validates the migration script. Can be used to test the script before running
help (h) -
Prints version
3.0.8
initializes migrations environment. Only need to run once
# prompt for init
migrate-consul init
? path: /path/to/migrations
? Name of migrations directory: migrations
# skip prompts and provide init
migrate-consul init /path/to/migrations migrations
Creates a template for a new migration script
# creates migration with default template
migrate-consul create my_description
# create migration with key filled in
migrate-consul create my_desciption --key path/to/key
# create migration with key and value filled in
migrate-consul create my_desciption --key path/to/key --value "my value"
# create migration with value from existing consul key
migrate-consul create my_desciption --key path/to/key --import
# create migration with value from existing consul key with ACL
migrate-consul create my_desciption --key path/to/key --import --token $CONSUL_ACL_TOKEN
# creates migration with default template and examples
migrate-consul create my_description --includeExamples
# recursivly creates multiple migrations for each key under existing consul path
migrate-consul create my_description --key path/to/root --import --recurse
Adds migrations to mongodb and hashes migration to ensure changes are not made at this point
# stage all new migrations and adds author of script
migrate-consul stage --author myname
# stage all new migrations in a different directory with a different config
migrate-consul stage --author myname --configPath /path/to/config --path /path/to/migrations
Removes pending or failed migrations from mongodb
# unstages most recent pending migration
migrate-consul unstage
# unstages migration with provided name
migrate-consul unstage --file 2022070112654-my_migration.ts
# unstages all pending migration
migrate-consul unstage --pending
# unstages all failed migration
migrate-consul unstage --failed
# unstages all pending or failed migrations from author
migrate-consul unstage --author myname
Runs script and prints output or errors to consul with optional diff from existing consul values
# verifies up script
migrate-consul verify
# verifies down script
migrate-consul verify down
# verifies up script and runs diff and prints diff patch
migrate-consul verify --diff patch
# verifies up script and runs diff and prints diff chars
migrate-consul verify --diff chars
# verifies up script and runs diff and prints diff words
migrate-consul verify --diff words
# verifies up script and runs diff and prints diff lines
migrate-consul verify --diff lines
# verifies up script and runs diff and prints diff json
migrate-consul verify --diff json
Runs all pending migrations up script
# run all pending
migrate-consul up
# forces run up even if hashes don't match (they have been edited without re-staging)
migrate-consul up --force
# run all pending migrations in a different directory with a different config
migrate-consul up --configPath /path/to/config --path /path/to/migrations
Runs down script on migrations per options
# runs down script of last migration
migrate-consul down
# runs down script of last 2 migrations
migrate-consul down --last 2
# runs down script of last 5 migrations
migrate-consul down --last 5
# run last down migration in a different directory with a different config
migrate-consul down --configPath /path/to/config --path /path/to/migrations
Prints a table of the status of all migrations
# print all statuses
migrate-consul status
Takes a backup of the provided keys and store them in mongo with a timestamp
# backup a single key
migrate-consul backup my/key
# backup multiple keys
migrate-consul backup my/key my/other/key
Restores key to consul from backup
# lists backups for key
migrate-consul restore my/key --list
# restore last backup for key
migrate-consul restore my/key --last
# restore backup from date
migrate-consul restore my/key --date 2022-07-08T01:48:18.183Z