Skip to content
Permalink
Browse files

fix(migration): crash if certain role types didn't exist

  • Loading branch information...
polonel committed Feb 24, 2019
1 parent 05eb49f commit 39dfaa223db5682c663ccd14508300b6ae703e4e
Showing with 18 additions and 9 deletions.
  1. +18 −9 src/migration/index.js
@@ -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')
}
})
},
@@ -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')
}
})
},
@@ -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')
}
})
}

0 comments on commit 39dfaa2

Please sign in to comment.
You can’t perform that action at this time.