Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix migration not running on colors

ammarahm-ed2bf6e7073c4e
diff --git a/packages/core/src/database/backup.js b/packages/core/src/database/backup.js
index 195178dbc..80c7810a2 100644
--- a/packages/core/src/database/backup.js
+++ b/packages/core/src/database/backup.js
@@ -251,9 +251,6 @@ export default class Backup {
if (!item || (!item.type && item.deleted)) continue;
// in v5.6 of the database, we did not set note history session's type
if (!item.type && item.sessionContentId) item.type = "notehistory";
- // colors are naively of type "tag" instead of "color" so we have to fix that.
- if (item.type === "tag" && COLORS.includes(item.title.toLowerCase()))
- item.type = "color";
await migrateItem(item, version, item.type, this._db, "backup");
// since items in trash can have their own set of migrations,
@@ -261,7 +258,13 @@ export default class Backup {
if (item.type === "trash" && item.itemType)
await migrateItem(item, version, item.itemType, this._db, "backup");
- const collectionKey = itemTypeToCollectionKey[item.itemType || item.type];
+ // colors are naively of type "tag" instead of "color" so we have to fix that.
+ const itemType =
+ item.type === "tag" && COLORS.includes(item.title.toLowerCase())
+ ? "color"
+ : item.itemType || item.type;
+
+ const collectionKey = itemTypeToCollectionKey[itemType];
if (collectionKey) {
toAdd[collectionKey] = toAdd[collectionKey] || [];
toAdd[collectionKey].push([item.id, item]);