clean up migrations

This commit is contained in:
Josh Harvey 2017-05-07 18:52:33 +03:00
parent 393f45a1b3
commit 94ee178c65
4 changed files with 40 additions and 38 deletions

View file

@ -4,7 +4,20 @@ const sequential = require('promise-sequential')
module.exports = {multi}
function multi (sqls, cb) {
return sequential(sqls.map(s => db.none(s)))
.then(cb)
.catch(cb)
const doQuery = s => {
return () => {
return db.none(s)
.catch(err => {
console.log(err.stack)
throw err
})
}
}
return sequential(sqls.map(doQuery))
.then(() => cb())
.catch(err => {
console.log(err.stack)
cb(err)
})
}