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

@ -256,7 +256,10 @@ async function removeAll() {
// erase everything in the database
}
async function getMessagesNeedingUpgrade(limit, { MessageCollection }) {
async function getMessagesNeedingUpgrade(
limit,
{ MessageCollection, maxVersion = MessageType.CURRENT_SCHEMA_VERSION }
) {
const messages = new MessageCollection();
await deferredToPromise(
@ -264,7 +267,7 @@ async function getMessagesNeedingUpgrade(limit, { MessageCollection }) {
limit,
index: {
name: 'schemaVersion',
upper: MessageType.CURRENT_SCHEMA_VERSION,
upper: maxVersion,
excludeUpper: true,
order: 'desc',
},