upgrade script fixes

v1.18.x
barisusakli 8 years ago
parent 520d6954c1
commit 1cf775a4b8

@ -84,19 +84,15 @@ Upgrade.check = function (callback) {
if (err) {
return callback(err);
}
console.log('available vs executed', files.length, executed.length);
var remainder = files.filter(function (name) {
return executed.indexOf(path.basename(name, '.js')) === -1;
});
next(remainder.length > 1 ? new Error('schema-out-of-date') : null);
next(remainder.length > 0 ? new Error('schema-out-of-date') : null);
});
},
], callback);
// var all = Upgrade.available.reduce(function (memo, current) {
// memo = memo.concat(current.upgrades);
// return memo;
// }, []);
};
Upgrade.run = function (callback) {
@ -161,7 +157,7 @@ Upgrade.process = function (files, skipCount, callback) {
process.stdout.write(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '... ');
// For backwards compatibility, cross-reference with schemaDate (if found). If a script's date is older, skip it
if (scriptExport.timestamp <= schemaDate && semver.lt(version, '1.5.0')) {
if (!schemaDate || (scriptExport.timestamp <= schemaDate && semver.lt(version, '1.5.0'))) {
process.stdout.write('skipped\n'.grey);
db.sortedSetAdd('schemaLog', Date.now(), path.basename(file, '.js'), next);
return;
@ -177,15 +173,15 @@ Upgrade.process = function (files, skipCount, callback) {
// Record success in schemaLog
db.sortedSetAdd('schemaLog', Date.now(), path.basename(file, '.js'), next);
});
}, function (err) {
if (err) {
return next(err);
}
process.stdout.write('Upgrade complete!\n\n'.green);
next();
});
}, next);
},
function (next) {
db.set('schemaDate', Date.now(), next);
},
function (next) {
process.stdout.write('Upgrade complete!\n\n'.green);
setImmediate(next);
}
], callback);
};

Loading…
Cancel
Save