Enable running multiple upgrades at once (#5984)

v1.18.x
Peter Jaszkowiak 7 years ago committed by Julian Lam
parent bf1e922cab
commit 1c5bdcb670

@ -219,14 +219,13 @@ function upgrade() {
var meta = require('./src/meta');
var upgrade = require('./src/upgrade');
var build = require('./src/meta/build');
var tasks = [db.init, meta.configs.init, upgrade.run, build.buildAll];
var tasks = [db.init, meta.configs.init];
if (nconf.get('upgrade') !== true) {
// Likely an upgrade script name passed in
tasks[2] = async.apply(upgrade.runSingle, nconf.get('upgrade'));
// Skip build
tasks.pop();
tasks.push(async.apply(upgrade.runParticular, nconf.get('upgrade').split(',')));
} else {
tasks.push(upgrade.run, build.buildAll);
}
// disable mongo timeouts during upgrade
nconf.set('mongo:options:socketTimeoutMS', 0);

@ -87,23 +87,19 @@ Upgrade.run = function (callback) {
});
};
Upgrade.runSingle = function (query, callback) {
Upgrade.runParticular = function (names, callback) {
process.stdout.write('\nParsing upgrade scripts... ');
async.waterfall([
async.apply(file.walk, path.join(__dirname, './upgrades')),
function (files, next) {
next(null, files.filter(function (file) {
return path.basename(file, '.js') === query;
}));
},
], function (err, files) {
if (err) {
return callback(err);
}
var upgrades = files.filter(function (file) {
return names.indexOf(path.basename(file, '.js')) !== -1;
});
Upgrade.process(files, 0, callback);
});
Upgrade.process(upgrades, 0, next);
},
], callback);
};
Upgrade.process = function (files, skipCount, callback) {

Loading…
Cancel
Save