mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
closes #642
This commit is contained in:
@@ -38,7 +38,8 @@ Upgrade.upgrade = function(callback) {
|
|||||||
|
|
||||||
Upgrade.upgradeRedis = function(callback) {
|
Upgrade.upgradeRedis = function(callback) {
|
||||||
|
|
||||||
var RDB = db.client;
|
var RDB = db.client,
|
||||||
|
updatesMade = false;
|
||||||
|
|
||||||
winston.info('Beginning Redis database schema update');
|
winston.info('Beginning Redis database schema update');
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
thisSchemaDate = new Date(2013, 9, 3).getTime();
|
thisSchemaDate = new Date(2013, 9, 3).getTime();
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
updatesMade = true;
|
||||||
async.series([
|
async.series([
|
||||||
function(next) {
|
function(next) {
|
||||||
RDB.keys('uid:*:notifications:flag', function(err, keys) {
|
RDB.keys('uid:*:notifications:flag', function(err, keys) {
|
||||||
@@ -110,6 +112,7 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
thisSchemaDate = new Date(2013, 9, 23).getTime();
|
thisSchemaDate = new Date(2013, 9, 23).getTime();
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
updatesMade = true;
|
||||||
RDB.keys('notifications:*', function(err, keys) {
|
RDB.keys('notifications:*', function(err, keys) {
|
||||||
|
|
||||||
keys = keys.filter(function(key) {
|
keys = keys.filter(function(key) {
|
||||||
@@ -139,6 +142,7 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
thisSchemaDate = new Date(2013, 10, 11).getTime();
|
thisSchemaDate = new Date(2013, 10, 11).getTime();
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
updatesMade = true;
|
||||||
RDB.hset('config', 'postDelay', 10, function(err, success) {
|
RDB.hset('config', 'postDelay', 10, function(err, success) {
|
||||||
winston.info('[2013/11/11] Updated postDelay to 10 seconds.');
|
winston.info('[2013/11/11] Updated postDelay to 10 seconds.');
|
||||||
next();
|
next();
|
||||||
@@ -151,6 +155,7 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
thisSchemaDate = new Date(2013, 10, 22).getTime();
|
thisSchemaDate = new Date(2013, 10, 22).getTime();
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
updatesMade = true;
|
||||||
RDB.keys('category:*', function(err, categories) {
|
RDB.keys('category:*', function(err, categories) {
|
||||||
async.each(categories, function(categoryStr, next) {
|
async.each(categories, function(categoryStr, next) {
|
||||||
var hex;
|
var hex;
|
||||||
@@ -197,6 +202,7 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
thisSchemaDate = new Date(2013, 10, 26).getTime();
|
thisSchemaDate = new Date(2013, 10, 26).getTime();
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
updatesMade = true;
|
||||||
categories.getAllCategories(0, function(err, categories) {
|
categories.getAllCategories(0, function(err, categories) {
|
||||||
|
|
||||||
function updateIcon(category, next) {
|
function updateIcon(category, next) {
|
||||||
@@ -237,7 +243,7 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
|
|
||||||
thisSchemaDate = new Date(2013, 11, 2).getTime();
|
thisSchemaDate = new Date(2013, 11, 2).getTime();
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
updatesMade = true;
|
||||||
var keys = [
|
var keys = [
|
||||||
'global:next_user_id',
|
'global:next_user_id',
|
||||||
'next_topic_id',
|
'next_topic_id',
|
||||||
@@ -276,14 +282,18 @@ Upgrade.upgradeRedis = function(callback) {
|
|||||||
winston.info('[2013/12/2] Update to global keys skipped');
|
winston.info('[2013/12/2] Update to global keys skipped');
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
// Add new schema updates here
|
// Add new schema updates here
|
||||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 12!!!
|
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 12!!!
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
RDB.set('schemaDate', thisSchemaDate, function(err) {
|
RDB.set('schemaDate', thisSchemaDate, function(err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
if(updatesMade) {
|
||||||
winston.info('[upgrade] Redis schema update complete!');
|
winston.info('[upgrade] Redis schema update complete!');
|
||||||
|
} else {
|
||||||
|
winston.info('[upgrade] Redis schema already up to date!');
|
||||||
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user