Skip to content

Commit

Permalink
Close connection; fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pateketrueke committed Jun 16, 2019
1 parent 81ba049 commit 5e0cc07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
4 changes: 3 additions & 1 deletion cli/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,7 @@ module.exports = (conn, config) => {
}

return check();
});
})
.then(() => conn.close())
.then(() => process.exit());
};
24 changes: 6 additions & 18 deletions lib/umzug.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,14 @@ module.exports = (sequelize, options, bind) => {
return umzug;
}

function end(p) {
return p.then(x => {
try {
sequelize.close();
} catch (e) {
console.warn(e);
} finally {
return x;
}
});
}

return {
run: script => end(Promise.resolve().then(() => fs.existsSync(script) && wrap(sequelize, require(script)))),
up: params => end(cmdMigrate(_umzug(), params || {})),
down: params => end(cmdReset(_umzug(), params || {})),
next: () => end(cmdMigrateNext(_umzug())),
prev: () => end(cmdResetPrev(_umzug())),
run: script => Promise.resolve().then(() => fs.existsSync(script) && wrap(sequelize, require(script))),
up: params => cmdMigrate(_umzug(), params || {}),
down: params => cmdReset(_umzug(), params || {}),
next: () => cmdMigrateNext(_umzug()),
prev: () => cmdResetPrev(_umzug()),
status: () => (fs.existsSync(_umzug().options.migrations.path)
? end(cmdStatus(_umzug()))
? cmdStatus(_umzug())
: Promise.resolve({
pending: [],
executed: [],
Expand Down

0 comments on commit 5e0cc07

Please sign in to comment.