Skip to content

Node.js based forum software built for the modern web

fix upgrade script to include main post, and fix post indices

barisusakli802c8b15e208
diff --git a/src/topics.js b/src/topics.js
index 4f011c937c..b57e63d3b0 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -357,7 +357,7 @@ var async = require('async'),
return next(err);
}
topics = topics.map(function(topic) {
- return topic && topic.postcount;
+ return topic && (parseInt(topic.postcount, 10) || 0);
});
next(null, topics);
@@ -409,7 +409,7 @@ var async = require('async'),
var teasers = tids.map(function(tid, index) {
if (tidToPost[tid]) {
- tidToPost[tid].index = results.counts[index] + 1;
+ tidToPost[tid].index = results.counts[index];
}
return tidToPost[tid];
});
diff --git a/src/upgrade.js b/src/upgrade.js
index 606dcf722f..7972247204 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, 9, 14);
+ latestSchema = Date.UTC(2014, 9, 22);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@@ -1114,7 +1114,7 @@ Upgrade.upgrade = function(callback) {
if (err) {
return next(err);
}
- count = parseInt(count, 10) || 0;
+ count = (parseInt(count, 10) || 0) + 1;
winston.info('updating tid ' + tid + ' count ' + count);
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) {
- winston.info('[2014/10/14] Topic post count migration');
+ winston.info('[2014/10/22] Topic post count migration');
async.series([
function(next) {
@@ -1135,14 +1135,14 @@ Upgrade.upgrade = function(callback) {
}
], function(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);
}
- winston.info('[2014/10/14] Topic post count migration done');
+ winston.info('[2014/10/22] Topic post count migration done');
Upgrade.update(thisSchemaDate, next);
});
} else {
- winston.info('[2014/10/14] Topic post count migration skipped');
+ winston.info('[2014/10/22] Topic post count migration skipped');
next();
}
}