Added warning for older MongoDB versions.
Ylian Saint-Hilaire committed
Jul 8, 2020 at 15:35 UTC
fc75bff5ad5973a2a4f3af21406fc4d92770b03b
1 file changed
+12
db.js
+12
@@ -391,6 +391,18 @@ module.exports.CreateDB = function (parent, func) {
391
const dbcollectionname = (parent.args.mongodbcol) ? (parent.args.mongodbcol) : 'meshcentral';
392
const db = client.db(dbname);
393
394
+ // Check the database version
395
+ db.admin().serverInfo(function (err, info) {
396
+ if ((err != null) || (info == null) || (info.versionArray == null) || (Array.isArray(info.versionArray) == false) || (info.versionArray.length < 2) || (typeof info.versionArray[0] != 'number') || (typeof info.versionArray[1] != 'number')) {
397
+ console.log('WARNING: Unable to check MongoDB version.');
398
+ } else {
399
+ if ((info.versionArray[0] < 3) || ((info.versionArray[0] == 3) && (info.versionArray[1] < 6))) {
400
+ // We are running with mongoDB older than 3.6, this is not good.
401
+ parent.addServerWarning("Current version of MongoDB (" + info.version + ") is too old, please upgrade to MongoDB 3.6 or better.");
402
+ }
403
+ }
404
+ });
405
+
406
// Setup MongoDB main collection and indexes
407
obj.file = db.collection(dbcollectionname);
408
obj.file.indexes(function (err, indexes) {