summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2014-02-28 08:45:02 -0500
committermatt dannenberg <matt.dannenberg@10gen.com>2014-03-03 09:44:35 -0500
commit6a10de0bb8fe996daca5ecd5687f1072abb0dd8b (patch)
tree82b1df61bb4366e5a820aa2480ece0ee1e8e934a
parent30074e8c048032c0c3cd3ebde349e83a3d56713a (diff)
downloadmongo-6a10de0bb8fe996daca5ecd5687f1072abb0dd8b.tar.gz
SERVER-8391 upgradechecker now supports database or collection as argument
-rw-r--r--src/mongo/shell/upgrade_check.js43
1 files 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: " +
+ "<dbNameString>, collection: <collectionNameString>} (either field may be omitted)");
+ return false;
+ }
+
+ print("\tChecking mongod instance for 2.6 upgrade compatibility");
var dbs = db.getMongo().getDBs();
var goodSoFar = true;