From 3aa4ae4b990317031d62ccbcc4c4a32aecaa3b1a Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 1 Apr 2014 11:48:15 -0400 Subject: [PATCH] move deprecated vanilla footer widgets into draft zone --- src/upgrade.js | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/upgrade.js b/src/upgrade.js index ea9aba4250..17326a8074 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -19,7 +19,7 @@ var db = require('./database'), schemaDate, thisSchemaDate, // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema - latestSchema = Date.UTC(2014, 3, 31, 12, 30); + latestSchema = Date.UTC(2014, 4, 2); Upgrade.check = function(callback) { db.get('schemaDate', function(err, value) { @@ -534,7 +534,39 @@ Upgrade.upgrade = function(callback) { winston.info('[2014/3/31] Re-adding copyright message into global footer widget - skipped'); next(); } - } + }, + function(next) { + thisSchemaDate = Date.UTC(2014, 4, 2); + + if (schemaDate < thisSchemaDate) { + db.getObjectField('widgets:home.tpl', 'footer', function(err, widgetData) { + if (err) { + winston.error('[2014/4/1] Error moving deprecated vanilla footer widgets into draft zone'); + return next(err); + } + + db.setObjectField('widgets:global', 'drafts', widgetData, function(err) { + if (err) { + winston.error('[2014/4/1] Error moving deprecated vanilla footer widgets into draft zone'); + return next(err); + } + + db.deleteObjectField('widgets:home.tpl', 'footer', function(err) { + if (err) { + winston.error('[2014/4/1] Error moving deprecated vanilla footer widgets into draft zone'); + next(err); + } else { + winston.info('[2014/4/1] Moved deprecated vanilla footer widgets into draft zone'); + Upgrade.update(thisSchemaDate, next); + } + }); + }); + }); + } else { + winston.info('[2014/4/1] Moved deprecated vanilla footer widgets into draft zone - skipped'); + next(); + } + }, // Add new schema updates here // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 22!!! ], function(err) {