From 41bea9f50cd6db51c7707280d761d45e8a874808 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 7 Sep 2013 19:01:17 -0400 Subject: [PATCH] adding upgradeAdmin method to upgrade script -- pending fix to upgradeUsers --- src/upgrade.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/upgrade.js b/src/upgrade.js index 40d2cc1758..687c579787 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -1,7 +1,8 @@ var RDB = require('./redis.js'), async = require('async'), winston = require('winston'), - user = require('./user'); + user = require('./user'), + Groups = require('./groups'); function upgradeCategory(cid, callback) { @@ -49,6 +50,32 @@ function upgradeUser(uid, callback) { }); } +function upgradeAdmins(callback) { + Groups.getGidFromName('Administrators', function(err, gid) { + if (!err && !gid) { + winston.info('Upgading Administrators'); + + async.parallel([ + function(next) { + RDB.smembers("administrators", next); + }, + function(next) { + Groups.create('Administrators', 'Forum Administrators', next); + } + ], function(err, results) { + var gid = results[1].gid; + + async.each(results[0], function(uid, next) { + Groups.join(gid, uid, next); + }, callback); + }); + } else { + winston.info('Administrators group OK') + callback(); + } + }); +} + exports.upgrade = function() { winston.info('upgrading nodebb now'); @@ -85,7 +112,8 @@ exports.upgrade = function() { }); }); - } + }, + upgradeAdmins ]; async.series(schema, function(err, results) {