mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-03 14:20:33 +01:00
upgrade script to clear sessions
This commit is contained in:
@@ -12,7 +12,7 @@ var schemaDate;
|
||||
var thisSchemaDate;
|
||||
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
var latestSchema = Date.UTC(2017, 1, 28);
|
||||
var latestSchema = Date.UTC(2017, 3, 16);
|
||||
|
||||
Upgrade.check = function (callback) {
|
||||
db.get('schemaDate', function (err, value) {
|
||||
@@ -425,6 +425,50 @@ Upgrade.upgrade = function (callback) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function (next) {
|
||||
thisSchemaDate = Date.UTC(2017, 3, 16);
|
||||
var schemaName = '[2017/4/16] Delete sessions';
|
||||
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
winston.info(schemaName);
|
||||
|
||||
var configJSON = require('../config.json');
|
||||
var isRedisSessionStore = configJSON.hasOwnProperty('redis');
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (isRedisSessionStore) {
|
||||
var rdb = require('./database/redis');
|
||||
var client = rdb.connect();
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
client.keys('sess:*', next);
|
||||
},
|
||||
function (sessionKeys, next) {
|
||||
async.eachSeries(sessionKeys, function (key, next) {
|
||||
client.del(key, next);
|
||||
}, next);
|
||||
},
|
||||
], function (err) {
|
||||
next(err);
|
||||
});
|
||||
} else {
|
||||
db.client.collection('sessions').drop({}, function (err) {
|
||||
next(err);
|
||||
});
|
||||
}
|
||||
},
|
||||
function (next) {
|
||||
winston.info(schemaName + ' - done');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
},
|
||||
], next);
|
||||
} else {
|
||||
winston.info(schemaName + ' - skipped!');
|
||||
next();
|
||||
}
|
||||
},
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
|
||||
], function (err) {
|
||||
|
||||
Reference in New Issue
Block a user