From 6a10de0bb8fe996daca5ecd5687f1072abb0dd8b Mon Sep 17 00:00:00 2001 From: matt dannenberg Date: Fri, 28 Feb 2014 08:45:02 -0500 Subject: SERVER-8391 upgradechecker now supports database or collection as argument --- src/mongo/shell/upgrade_check.js | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/mongo/shell/upgrade_check.js b/src/mongo/shell/upgrade_check.js index 4efa6a39f9d..3175b8d4134 100644 --- a/src/mongo/shell/upgrade_check.js +++ b/src/mongo/shell/upgrade_check.js @@ -96,8 +96,47 @@ dbUpgradeCheck = function(dbName) { return goodSoFar; } -upgradeCheck = function() { - print("\tChecking for 2.6 upgrade compatibility"); +upgradeCheck = function(obj) { + // parse args if there are any + if (obj) { + // check collection if a collection is passed + if (obj["collection"]) { + // make sure a string was passed in for the collection + if (typeof obj["collection"] !== "string") { + print("The collection field must contain a string"); + return false; + } + } + + if (obj["db"]) { + // make sure a string was passed in for the db + if (typeof obj["db"] !== "string") { + print("The db field must contain a string"); + return false; + } + + // check only the collection if it was passed it + if (obj["collection"]) { + print("\tChecking collection '" + obj["db"] + '.' + obj["collection"] + + "' for 2.6 upgrade compatibility"); + return collUpgradeCheck(obj["db"], obj["collection"]); + } + + //otherwise check entire db + print("\tChecking database '" + obj["db"] + "' for 2.6 upgrade compatibility"); + return dbUpgradeCheck(obj["db"]); + } + if (obj["collection"]) { + print("\tChecking collection '" + db.getName() + '.' + obj["collection"] + + "' for 2.6 upgrade compatibility"); + return collUpgradeCheck(db.getName(), obj["collection"]); + } + print("When passing an argument to upgradeCheck, it must be of the form {db: " + + ", collection: } (either field may be omitted)"); + return false; + } + + print("\tChecking mongod instance for 2.6 upgrade compatibility"); var dbs = db.getMongo().getDBs(); var goodSoFar = true; -- cgit v1.2.1