upgrade.js - categories.numRecentTopics

v1.18.x
psychobunny 11 years ago
parent d28beaa4dc
commit fb53e89023

@ -86,7 +86,7 @@
<div class="col-sm-4 col-xs-12">
<div class="form-group">
<label for="cid-{categories.cid}-numRecentTopics"># of Recent Topics Displayed</label>
<input id="cid-{categories.cid}-numRecentTopics" type="text" class="form-control" placeholder="2" data-name="numRecentTopics" value="{categories.show}" />
<input id="cid-{categories.cid}-numRecentTopics" type="text" class="form-control" placeholder="2" data-name="numRecentTopics" value="{categories.numRecentTopics}" />
</div>
</div>
</div>

@ -14,7 +14,7 @@ var db = require('./database'),
Upgrade.check = function(callback) {
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
var latestSchema = new Date(2014, 0, 3).getTime();
var latestSchema = new Date(2014, 0, 4).getTime();
db.get('schemaDate', function(err, value) {
if (parseInt(value, 10) >= latestSchema) {
@ -132,6 +132,29 @@ Upgrade.upgrade = function(callback) {
winston.info('[2014/1/3] categories.class, categories.link fields skipped');
next();
}
},
function(next) {
// Custom classes for each category, adding link field for each category
thisSchemaDate = new Date(2014, 0, 4).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
db.getListRange('categories:cid', 0, -1, function(err, cids) {
if(err) {
return next(err);
}
for (var cid in cids) {
db.setObjectField('category:' + cids[cid], 'numRecentTopics', '2');
}
winston.info('[2013/12/31] Added categories.numRecentTopics fields');
next();
});
} else {
winston.info('[2014/1/3] categories.numRecentTopics fields skipped');
next();
}
}
// Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!

Loading…
Cancel
Save