Node.js based forum software built for the modern web
Merge branch 'develop' into upgrades-refactor
Julian Lam67e8bab78359
diff --cc src/upgrade.jsindex f7b5457467,2bedd38d00..8978f5e60a--- a/src/upgrade.js+++ b/src/upgrade.js@@@ -1,68 -1,21 +1,68 @@@-'use strict';+/* jslint node: true */+'use strict';-var db = require('./database');var async = require('async');-var winston = require('winston');--var Upgrade = {};+var path = require('path');-var minSchemaDate = Date.UTC(2016, 8, 7); // This value gets updated every new MAJOR version-var schemaDate;-var thisSchemaDate;--// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema-var latestSchema = Date.UTC(2017, 1, 28);+var db = require('./database');+var utils = require('../public/src/utils');++/*+ * Need to write an upgrade script for NodeBB? Cool.+ *+ * 1. Copy TEMPLATE to a file name of your choice. Try to be succinct.+ * 2. Open up that file and change the user-friendly name (can be longer/more descriptive than the file name)+ * and timestamp+ * 3. Add your script under the "method" property+ * 4. Append your filename to the array below for the next NodeBB version.+ */++var Upgrade = {+ available: [+ {+ version: '1.0.0',+ upgrades: ['chat_upgrade', 'chat_room_hashes', 'theme_to_active_plugins', 'user_best_posts', 'users_notvalidated', 'global_moderators', 'social_post_sharing'],+ },+ {+ version: '1.1.0',+ upgrades: ['group_title_update', 'user_post_count_per_tid', 'dismiss_flags_from_deleted_topics', 'assign_topic_read_privilege', 'separate_upvote_downvote'],+ },+ {+ version: '1.1.1',+ upgrades: ['upload_privileges', 'remove_negative_best_posts'],+ },+ {+ version: '1.2.0',+ upgrades: ['category_recent_tids', 'edit_delete_deletetopic_privileges'],+ },+ {+ version: '1.3.0',+ upgrades: ['favourites_to_bookmarks', 'sorted_sets_for_post_replies'],+ },+ {+ version: '1.4.0',+ upgrades: ['global_and_user_language_keys', 'sorted_set_for_pinned_topics'],+ },+ {+ version: 'master', // rename this to whenever the next NodeBB version is (non-breaking)- upgrades: ['sound_settings', 'post_votes_zset', 'config_urls_update'],++ upgrades: ['sound_settings', 'config_urls_update'],+ },+ {+ version: 'develop', // rename this to whatever the next NodeBB version is (breaking)- upgrades: ['flags_refactor'],++ upgrades: ['flags_refactor', 'post_votes_zset'],+ },+ ],+};Upgrade.check = function (callback) {- db.get('schemaDate', function (err, value) {+ // Throw 'schema-out-of-date' if not all upgrade scripts have run+ var all = Upgrade.available.reduce(function (memo, current) {+ memo = memo.concat(current.upgrades);+ return memo;+ }, []);++ db.getSortedSetRange('schemaLog', 0, -1, function (err, executed) {if (err) {return callback(err);}