From 6cb000c7819cea2fa0bd3ac1df2e47c26e6e121e Mon Sep 17 00:00:00 2001 From: Rishabh Joshi Date: Fri, 17 Feb 2017 10:07:37 +0530 Subject: [PATCH] XOL-3345 Added db update script for upgrading to v0.2.2 and later. --- db/mailchimp.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/mailchimp.js diff --git a/db/mailchimp.js b/db/mailchimp.js new file mode 100644 index 0000000..55485fb --- /dev/null +++ b/db/mailchimp.js @@ -0,0 +1,19 @@ +// Execute this script only if you're upgrading to v0.2.2 or later. +// Not required for a fresh db. + +use mailchimp; + +// Add type data to preference fields of the installations +var cursor = db.getCollection('installations').find({}); +while (cursor.hasNext()) { + var obj1 = cursor.next(); + var prefs = obj1.preferences; + if (prefs) { + prefs.forEach(function (item) { + item.values.forEach(function (vals) { + vals['type'] = 'string'; + }); + }); + } + db.getCollection('installations').update({'_id': obj1._id}, obj1); +}