Introduce mandatary migration on startup, to minimum version

This commit is contained in:
Scott Nonnenberg
2018-07-26 19:19:34 -07:00
parent f38647dfa5
commit 02675312c5
5 changed files with 122 additions and 49 deletions

View File

@@ -296,6 +296,7 @@ exports.upgradeSchema = async (
makeImageThumbnail,
makeVideoScreenshot,
logger,
maxVersion = exports.CURRENT_SCHEMA_VERSION,
} = {}
) => {
if (!isFunction(writeNewAttachmentData)) {
@@ -328,7 +329,12 @@ exports.upgradeSchema = async (
let message = rawMessage;
// eslint-disable-next-line no-restricted-syntax
for (const currentVersion of VERSIONS) {
for (let index = 0, max = VERSIONS.length; index < max; index += 1) {
if (maxVersion < index) {
break;
}
const currentVersion = VERSIONS[index];
// We really do want this intra-loop await because this is a chained async action,
// each step dependent on the previous
// eslint-disable-next-line no-await-in-loop