File: //usr/local/bin/knex-migrator-rollback
#!/usr/bin/env node
const program = require('commander');
const utils = require('../lib/utils');
const logging = require('../logging');
let knexMigrator;
utils.getKnexMigrator({path: process.cwd()})
.then(function (KnexMigrator) {
program
.option('--mgpath <path>')
.option('--force')
.option('--v <version>', 'The version to rollback to.')
.parse(process.argv);
try {
knexMigrator = new KnexMigrator({knexMigratorFilePath: program.mgpath, executedFromShell: true});
} catch (err) {
logging.error(err);
process.exit(1);
}
return knexMigrator.rollback({force: program.force, version: program.v})
.then(function () {
logging.info('Rollback was successful.');
});
})
.catch(function (err) {
logging.error(err.message);
if (err.help) {
logging.info(err.help);
}
process.exit(1);
});