Skip to content

Commit

Permalink
🐛 Fixed option collision with commander (--version vs --v)
Browse files Browse the repository at this point in the history
no issue

- `--version` is a reserved option (see tj/commander.js#648). Same applies to `--name` etc.
- We have to use `--v` for now.
- This is in theory a breaking change, but the feature never worked when using `knex-migrator rollback --version x.x.x` in the shell
  - that's why it's a bug fix
- updated docs
  • Loading branch information
kirrg001 committed Aug 6, 2018
1 parent 94f4363 commit 17bdc2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -102,6 +102,8 @@ knex-migrator reset [resets your database]
knex-migrator reset --force [resets your database and ignores the migration lock]
knex-migrator rollback
knex-migrator rollback --force
knex-migrator rollback --force --v 1.20.0
```

### JS
Expand Down
10 changes: 5 additions & 5 deletions bin/knex-migrator-rollback
@@ -1,17 +1,17 @@
#!/usr/bin/env node

let program = require('commander');
let utils = require('../lib/utils');
const program = require('commander');
const utils = require('../lib/utils');

let logging = require('../logging');
const logging = require('../logging');
let knexMigrator;

utils.getKnexMigrator({path: process.cwd()})
.then(function (KnexMigrator) {
program
.option('--mgpath <path>')
.option('--force')
.option('--version')
.option('--v <version>', 'The version to rollback to.')
.parse(process.argv);

try {
Expand All @@ -21,7 +21,7 @@ utils.getKnexMigrator({path: process.cwd()})
process.exit(1);
}

return knexMigrator.rollback({force: program.force, version: program.version})
return knexMigrator.rollback({force: program.force, version: program.v})
.then(function () {
logging.info('Rollback was successful.');
});
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -1130,7 +1130,7 @@ KnexMigrator.prototype.isDatabaseOK = function isDatabaseOK() {
* You can pass `--force` to skip this.
*
* `knex-migrator rollback --force` does only rollback the current version you are on.
* `knex-migrator rollback --force --version 1.20` does rollback all migration scripts between the version you are on
* `knex-migrator rollback --force --v 1.20` does rollback all migration scripts between the version you are on
* and to the version you have specified (but this version is excluded).
*
* "Rollback to version 1.22" => That means i want to bring back my blog to 1.22. Rollback 1.23, 1.24 etc.
Expand Down

0 comments on commit 17bdc2e

Please sign in to comment.