Improved migrations

This commit is contained in:
Stefan Zermatten
2023-06-23 09:42:14 +02:00
parent bae621cd47
commit 81cfc3919e
2 changed files with 14 additions and 2 deletions

View File

@@ -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') {

View File

@@ -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);
}