Add Message schema version 3

This commit is contained in:
Daniel Gasienica 2018-03-14 20:45:33 -04:00
parent e0428355be
commit 2cd3d5ac16
2 changed files with 21 additions and 8 deletions

View file

@ -13,9 +13,11 @@ const PRIVATE = 'private';
// Version 0
// - Schema initialized
// Version 1
// - Attachments: Auto-orient JPEG attachments using EXIF `Orientation` data
// - Attachments: Auto-orient JPEG attachments using EXIF `Orientation` data.
// Version 2
// - Attachments: Sanitize Unicode order override characters
// - Attachments: Sanitize Unicode order override characters.
// Version 3
// - Attachments: Write attachment data to disk and store relative path to it.
const INITIAL_SCHEMA_VERSION = 0;
// Increment this version number every time we add a message schema upgrade
@ -23,7 +25,7 @@ const INITIAL_SCHEMA_VERSION = 0;
// add more upgrade steps, we could design a pipeline that does this
// incrementally, e.g. from version 0 / unknown -> 1, 1 --> 2, etc., similar to
// how we do database migrations:
exports.CURRENT_SCHEMA_VERSION = 2;
exports.CURRENT_SCHEMA_VERSION = 3;
// Public API
@ -163,5 +165,8 @@ const toVersion3 = exports._withSchemaVersion(
);
// UpgradeStep
exports.upgradeSchema = async (message, context) =>
toVersion2(await toVersion1(await toVersion0(message)));
exports.upgradeSchema = async (message, { writeAttachmentData } = {}) =>
toVersion3(
await toVersion2(await toVersion1(await toVersion0(message))),
{ writeAttachmentData }
);