mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
fix upgrade script to include main post, and fix post indices
This commit is contained in:
@@ -357,7 +357,7 @@ var async = require('async'),
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
topics = topics.map(function(topic) {
|
topics = topics.map(function(topic) {
|
||||||
return topic && topic.postcount;
|
return topic && (parseInt(topic.postcount, 10) || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
next(null, topics);
|
next(null, topics);
|
||||||
@@ -409,7 +409,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
var teasers = tids.map(function(tid, index) {
|
var teasers = tids.map(function(tid, index) {
|
||||||
if (tidToPost[tid]) {
|
if (tidToPost[tid]) {
|
||||||
tidToPost[tid].index = results.counts[index] + 1;
|
tidToPost[tid].index = results.counts[index];
|
||||||
}
|
}
|
||||||
return tidToPost[tid];
|
return tidToPost[tid];
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var db = require('./database'),
|
|||||||
schemaDate, thisSchemaDate,
|
schemaDate, thisSchemaDate,
|
||||||
|
|
||||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||||
latestSchema = Date.UTC(2014, 9, 14);
|
latestSchema = Date.UTC(2014, 9, 22);
|
||||||
|
|
||||||
Upgrade.check = function(callback) {
|
Upgrade.check = function(callback) {
|
||||||
db.get('schemaDate', function(err, value) {
|
db.get('schemaDate', function(err, value) {
|
||||||
@@ -1114,7 +1114,7 @@ Upgrade.upgrade = function(callback) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
count = parseInt(count, 10) || 0;
|
count = (parseInt(count, 10) || 0) + 1;
|
||||||
winston.info('updating tid ' + tid + ' count ' + count);
|
winston.info('updating tid ' + tid + ' count ' + count);
|
||||||
db.setObjectField('topic:' + tid, 'postcount', count, next);
|
db.setObjectField('topic:' + tid, 'postcount', count, next);
|
||||||
});
|
});
|
||||||
@@ -1122,9 +1122,9 @@ Upgrade.upgrade = function(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
thisSchemaDate = Date.UTC(2014, 9, 14);
|
thisSchemaDate = Date.UTC(2014, 9, 22);
|
||||||
if (schemaDate < thisSchemaDate) {
|
if (schemaDate < thisSchemaDate) {
|
||||||
winston.info('[2014/10/14] Topic post count migration');
|
winston.info('[2014/10/22] Topic post count migration');
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
function(next) {
|
function(next) {
|
||||||
@@ -1135,14 +1135,14 @@ Upgrade.upgrade = function(callback) {
|
|||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('[2014/10/14] Error encountered while Topic post count migration');
|
winston.error('[2014/10/22] Error encountered while Topic post count migration');
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
winston.info('[2014/10/14] Topic post count migration done');
|
winston.info('[2014/10/22] Topic post count migration done');
|
||||||
Upgrade.update(thisSchemaDate, next);
|
Upgrade.update(thisSchemaDate, next);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
winston.info('[2014/10/14] Topic post count migration skipped');
|
winston.info('[2014/10/22] Topic post count migration skipped');
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user