Skip to content

Commit

Permalink
fix(migration): crash if certain role types didn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Feb 24, 2019
1 parent 05eb49f commit 39dfaa2
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/migration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ function migrateUserRoles (callback) {
userSchema.collection.updateMany({ role: 'admin' }, { $set: { role: adminRole._id } }).then(function (res) {
if (res && res.result) {
if (res.result.ok === 1) return next(null, roles)

winston.warn(res.message)
return next(res.message)
else {
winston.warn(res.message)
return next(res.message)
}
} else {
return next('Unknown Error Occurred')
}
})
},
Expand All @@ -93,9 +96,12 @@ function migrateUserRoles (callback) {
.then(function (res) {
if (res && res.result) {
if (res.result.ok === 1) return next(null, roles)

winston.warn(res.message)
return next(res.message)
else {
winston.warn(res.message)
return next(res.message)
}
} else {
return next('Unknown Error Occurred')
}
})
},
Expand All @@ -104,9 +110,12 @@ function migrateUserRoles (callback) {
userSchema.collection.updateMany({ role: 'user' }, { $set: { role: userRole._id } }).then(function (res) {
if (res && res.result) {
if (res.result.ok === 1) return next(null, roles)

winston.warn(res.message)
return next(res.message)
else {
winston.warn(res.message)
return next(res.message)
}
} else {
return next('Unknown Error Occurred')
}
})
}
Expand Down

0 comments on commit 39dfaa2

Please sign in to comment.