From 16bb7b3116890804277c656347e27e531d6b21e0 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Thu, 26 Mar 2015 12:07:30 +0900 Subject: [PATCH] test for presence of settings --- server/migrations.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/server/migrations.js b/server/migrations.js index 3c2d4b9723..270ae9855f 100644 --- a/server/migrations.js +++ b/server/migrations.js @@ -500,19 +500,24 @@ var migrationsList = { var settings = Settings.findOne(); var set = {}; - if (!!settings.buttonColor) - set.accentColor = settings.buttonColor; + if (!!settings) { - if (!!settings.buttonTextColor) - set.accentContrastColor = settings.buttonTextColor; + if (!!settings.buttonColor) + set.accentColor = settings.buttonColor; - if (!!settings.buttonColor) - set.secondaryColor = settings.headerColor; + if (!!settings.buttonTextColor) + set.accentContrastColor = settings.buttonTextColor; + + if (!!settings.buttonColor) + set.secondaryColor = settings.headerColor; + + if (!!settings.buttonColor) + set.secondaryContrastColor = settings.headerTextColor; + + if (!_.isEmpty(set)) { + Settings.update(settings._id, {$set: set}, {validate: false}); + } - if (!!settings.buttonColor) - set.secondaryContrastColor = settings.headerTextColor; - if (!_.isEmpty(set)) { - Settings.update(settings._id, {$set: set}, {validate: false}); } return i; },