diff --git a/src/upgrade.js b/src/upgrade.js index ba3d7a9e0e..2bedd38d00 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -407,6 +407,46 @@ Upgrade.upgrade = function (callback) { next(); } }, + function (next) { + thisSchemaDate = Date.UTC(2017, 1, 28); + var schemaName = '[2017/2/28] Update urls in config to `/assets`'; + + if (schemaDate < thisSchemaDate) { + updatesMade = true; + winston.info(schemaName); + async.waterfall([ + function (cb) { + db.getObject('config', cb); + }, + function (config, cb) { + if (!config) { + return cb(); + } + + var keys = ['brand:favicon', 'brand:touchicon', 'og:image', 'brand:logo:url', 'defaultAvatar', 'profile:defaultCovers']; + + keys.forEach(function (key) { + var oldValue = config[key]; + + if (!oldValue || typeof oldValue !== 'string') { + return; + } + + config[key] = oldValue.replace(/(?:\/assets)?\/(images|uploads)\//g, '/assets/$1/'); + }); + + db.setObject('config', config, cb); + }, + function (next) { + winston.info(schemaName + ' - done'); + Upgrade.update(thisSchemaDate, next); + }, + ], next); + } else { + winston.info(schemaName + ' - skipped!'); + next(); + } + }, function (next) { thisSchemaDate = Date.UTC(2017, 1, 25); var schemaName = '[2017/2/25] Update global and user sound settings'; @@ -479,46 +519,6 @@ Upgrade.upgrade = function (callback) { next(); } }, - function (next) { - thisSchemaDate = Date.UTC(2017, 1, 28); - var schemaName = '[2017/2/28] Update urls in config to `/assets`'; - - if (schemaDate < thisSchemaDate) { - updatesMade = true; - winston.info(schemaName); - async.waterfall([ - function (cb) { - db.getObject('config', cb); - }, - function (config, cb) { - if (!config) { - return cb(); - } - - var keys = ['brand:favicon', 'brand:touchicon', 'og:image', 'brand:logo:url', 'defaultAvatar', 'profile:defaultCovers']; - - keys.forEach(function (key) { - var oldValue = config[key]; - - if (!oldValue || typeof oldValue !== 'string') { - return; - } - - config[key] = oldValue.replace(/(?:\/assets)?\/(images|uploads)\//g, '/assets/$1/'); - }); - - db.setObject('config', config, cb); - }, - function (next) { - winston.info(schemaName + ' - done'); - Upgrade.update(thisSchemaDate, next); - }, - ], next); - } else { - winston.info(schemaName + ' - skipped!'); - next(); - } - }, function (next) { thisSchemaDate = Date.UTC(2017, 1, 27); var schemaName = '[2017/2/27] New sorted set posts:votes';