From 81cfc3919e7c3e4b15e04d266699de2ddc071e14 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Fri, 23 Jun 2023 09:42:14 +0200 Subject: [PATCH] Improved migrations --- app/imports/migrations/archive/migrateArchive1To2.js | 4 ++++ app/imports/migrations/server/dbv2/dbv2.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/imports/migrations/archive/migrateArchive1To2.js b/app/imports/migrations/archive/migrateArchive1To2.js index 5bbe75d1..b9a6c2a7 100644 --- a/app/imports/migrations/archive/migrateArchive1To2.js +++ b/app/imports/migrations/archive/migrateArchive1To2.js @@ -10,6 +10,10 @@ export default function migrate1To2(archive) { // Migrate slot fillers to folders if (prop.type === 'slotFiller') { prop.type = 'folder'; + // If the slot filler has a description, change it to a computed one + if (typeof prop.description == 'string') { + prop.description = { text: prop.description }; + } } // Migrate slot filler slot type to folders if (prop.slotType === 'slotFiller') { diff --git a/app/imports/migrations/server/dbv2/dbv2.js b/app/imports/migrations/server/dbv2/dbv2.js index 4865a185..59a7eeb3 100644 --- a/app/imports/migrations/server/dbv2/dbv2.js +++ b/app/imports/migrations/server/dbv2/dbv2.js @@ -51,6 +51,10 @@ export function migratePropUp(prop, collection) { update.$set.slotFillImage = prop.picture; update.$unset = { picture: 1 }; } + // If the slot filler has a description, change it to a computed one + if (typeof prop.description == 'string') { + prop.description = { text: prop.description }; + } } // Don't look for slot fillers @@ -73,7 +77,9 @@ export function migratePropUp(prop, collection) { // update the document if (update) { try { - collection.update({ _id: prop._id }, update, { bypassCollection2: true }); + collection.update({ _id: prop._id }, update, { bypassCollection2: true }, e => { + if (e) console.warn('Doc Migration failed: ', prop._id, e); + }); } catch (e) { console.warn('Doc Migration failed: ', prop._id, e); } @@ -97,7 +103,9 @@ export function migratePropDown(prop, collection) { } if (update) { try { - collection.update({ _id: prop._id }, update, { bypassCollection2: true }); + collection.update({ _id: prop._id }, update, { bypassCollection2: true }, e => { + if (e) console.warn('Doc Migration failed: ', prop._id, e); + }); } catch (e) { console.warn('Doc Migration failed: ', prop._id, e); }