Skip to content

Node.js based forum software built for the modern web

upgrade script fixes

barisusakli1cf775a4b87a
diff --git a/src/upgrade.js b/src/upgrade.js
index 540543cf7b..09604f809e 100644
--- a/src/upgrade.js
+++ b/src/upgrade.js
@@ -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);
};