node-pg-migrate
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -65,2 +65,3 @@ 'use strict'; | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var log = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : console.log; | ||
@@ -75,2 +76,3 @@ _classCallCheck(this, Migration); | ||
this.options = options; | ||
this.log = log; | ||
} | ||
@@ -100,10 +102,10 @@ | ||
switch (action) { | ||
case _this.down: | ||
_this.log(`### MIGRATION ${_this.name} (DOWN) ###`); | ||
sql_steps.push(`DELETE FROM "${schema}"."${_this.options.migrations_table}" WHERE name='${_this.name}';`); | ||
break; | ||
case _this.up: | ||
console.log(`### MIGRATION ${_this.name} (UP) ###`); | ||
_this.log(`### MIGRATION ${_this.name} (UP) ###`); | ||
sql_steps.push(`INSERT INTO "${schema}"."${_this.options.migrations_table}" (name, run_on) VALUES ('${_this.name}', NOW());`); | ||
break; | ||
case _this.down: | ||
console.log(`### MIGRATION ${_this.name} (DOWN) ###`); | ||
sql_steps.push(`DELETE FROM "${schema}"."${_this.options.migrations_table}" WHERE name='${_this.name}';`); | ||
break; | ||
default: | ||
@@ -118,6 +120,6 @@ throw new Error('Unknown direction'); | ||
} else { | ||
console.log('#> WARNING: This migration is not wrapped in a transaction! <'); | ||
_this.log('#> WARNING: This migration is not wrapped in a transaction! <'); | ||
} | ||
console.log(`${sql_steps.join('\n')}\n\n`); | ||
_this.log(`${sql_steps.join('\n')}\n\n`); | ||
@@ -124,0 +126,0 @@ return sql_steps.reduce(function (promise, sql) { |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"engines": { | ||
@@ -45,11 +45,14 @@ "node": ">=4.0.0" | ||
"babel-preset-stage-3": "^6.24.0", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"config": ">=1.0.0", | ||
"cross-env": "^4.0.0", | ||
"cross-env": "^5.0.0", | ||
"dotenv": ">=1.0.0", | ||
"eslint": "^3.17.0", | ||
"eslint-config-airbnb-base": "11.1.3", | ||
"eslint-config-airbnb-base": "11.2.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"mocha": "^3.2.0", | ||
"pg": "^6.1.0", | ||
"sinon": "^2.1.0" | ||
"mocha": "^3.4.1", | ||
"pg": "^6.2.2", | ||
"sinon": "^2.1.0", | ||
"sinon-chai": "^2.10.0" | ||
}, | ||
@@ -65,3 +68,3 @@ "peerDependencies": { | ||
"compile": "babel lib/ -d dist/ && cp lib/migration-template.js dist/", | ||
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-core/register test", | ||
"test": "cross-env NODE_ENV=test mocha --opts ./mocha.opts test", | ||
"lint": "eslint -c .eslintrc . bin/pg-migrate", | ||
@@ -68,0 +71,0 @@ "lintfix": "npm run lint -- --fix", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
114910
29
706
17