anydb-sql-migrations
Advanced tools
Comparing version 2.1.6 to 2.2.0
"use strict"; | ||
exports.__esModule = true; | ||
var Promise = require("bluebird"); | ||
@@ -42,3 +41,3 @@ var _ = require("lodash"); | ||
function remove(tx, name) { | ||
return migrations.where({ version: name })["delete"]().execWithin(tx); | ||
return migrations.where({ version: name }).delete().execWithin(tx); | ||
} | ||
@@ -89,3 +88,6 @@ function runSingle(tx, type, m) { | ||
var args = require('yargs').argv; | ||
if (args.check) | ||
return execMigrations(args).then(function () { return process.exit(0); }).catch(function (e) { return process.exit(1); }); | ||
} | ||
function execMigrations(migrationOptions) { | ||
if (migrationOptions.check) | ||
return check(function (migrations) { | ||
@@ -95,16 +97,16 @@ if (migrations.length) { | ||
migrations.forEach(function (item) { return console.log("-", item.name); }); | ||
process.exit(1); | ||
return Promise.resolve(); | ||
} | ||
else { | ||
console.log("No pending migrations"); | ||
process.exit(0); | ||
return Promise.resolve(); | ||
} | ||
}); | ||
else if (args.execute) | ||
return migrate().done(function (_) { return process.exit(0); }, function (e) { | ||
else if (migrationOptions.execute) | ||
return migrate().done(function (_) { return Promise.resolve(); }, function (e) { | ||
console.error(e.stack); | ||
process.exit(1); | ||
return Promise.reject(e); | ||
}); | ||
else if (args.rollback) { | ||
return undoLast().done(function (_) { return process.exit(0); }, function (e) { | ||
else if (migrationOptions.rollback) { | ||
return undoLast().done(function (_) { return Promise.resolve(); }, function (e) { | ||
if (e.message == 'No migrations available to rollback') { | ||
@@ -116,7 +118,7 @@ console.error(e.message); | ||
} | ||
process.exit(1); | ||
return Promise.reject(e); | ||
}); | ||
} | ||
else if (args.drop) { | ||
return undoAll().done(function (_) { return process.exit(0); }, function (e) { | ||
else if (migrationOptions.drop) { | ||
return undoAll().done(function (_) { return Promise.resolve(); }, function (e) { | ||
if (e.message == 'No migrations available to rollback') { | ||
@@ -128,7 +130,8 @@ console.error(e.message); | ||
} | ||
process.exit(1); | ||
return Promise.reject(e); | ||
}); | ||
} | ||
console.error("Add a --check, --execute, --drop or --rollback argument"); | ||
process.exit(1); | ||
var wrontArgumentMessage = "Add a --check, --execute, --drop or --rollback argument"; | ||
console.error(wrontArgumentMessage); | ||
return Promise.resolve(new Error(wrontArgumentMessage)); | ||
} | ||
@@ -142,2 +145,1 @@ if (typeof tasks === 'string') | ||
exports.create = create; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "anydb-sql-migrations", | ||
"version": "2.1.6", | ||
"version": "2.2.0", | ||
"description": "Database migrations for anydb-sql", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -53,4 +53,12 @@ ## anydb-sql-migrations | ||
If you want to run the migrations from JavaScript code instead of cli, you can pass `{ execute: true }` to `run` function | ||
```js | ||
require('anydb-sql-migrate') | ||
.create(myanydbsql, '/path/to/migrations/dir') | ||
.run({ execute: true }); // will use this argument instead of reading from process.argv | ||
``` | ||
# license | ||
MIT |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88577
25
1385
64
1