tweaking upgrade script

v1.18.x
Julian Lam 11 years ago
parent 3f0f5a09a0
commit 4923c79496

@ -209,32 +209,43 @@ Upgrade.upgrade = function(callback) {
} }
}, },
function(next) { function(next) {
thisSchemaDate = new Date(2014, 0, 5, 14, 5).getTime(); thisSchemaDate = new Date(2014, 0, 5, 14, 6).getTime();
if (schemaDate < thisSchemaDate) { if (schemaDate < thisSchemaDate) {
updatesMade = true; updatesMade = true;
// Re-slugify all users // Re-slugify all users
db.getObjectValues('username:uid', function(err, uids) { db.delete('userslug:uid', function(err) {
var newUserSlug; if (!err) {
db.getObjectValues('username:uid', function(err, uids) {
var newUserSlug;
async.each(uids, function(uid, next) { async.each(uids, function(uid, next) {
User.getUserField(uid, 'username', function(err, username) { User.getUserField(uid, 'username', function(err, username) {
if(err) { if(err) {
return next(err); return next(err);
} }
if(username) { if(username) {
newUserSlug = Utils.slugify(username); newUserSlug = Utils.slugify(username);
User.setUserField(uid, 'userslug', newUserSlug, next); async.parallel([
} else { function(next) {
winston.warn('uid '+ uid + ' doesn\'t have a valid username (' + username + '), skipping'); User.setUserField(uid, 'userslug', newUserSlug, next);
next(null); },
} function(next) {
db.setObjectField('userslug:uid', newUserSlug, uid, next);
}
], next);
} else {
winston.warn('uid '+ uid + ' doesn\'t have a valid username (' + username + '), skipping');
next(null);
}
});
}, function(err) {
winston.info('[2014/1/5] Re-slugify usernames (again)');
next(err);
});
}); });
}, function(err) { }
winston.info('[2014/1/5] Re-slugify usernames (again)'); })
next(err);
});
});
} else { } else {
winston.info('[2014/1/5] Re-slugify usernames (again) skipped'); winston.info('[2014/1/5] Re-slugify usernames (again) skipped');
next(); next();

Loading…
Cancel
Save