Skip to content

Commit

Permalink
fix(richtext-lexical): ensure errors during slate => lexical migratio…
Browse files Browse the repository at this point in the history
…n are caught and do not halt migration progress
  • Loading branch information
AlessioGr committed Aug 21, 2024
1 parent 9beaa28 commit cf66341
Showing 1 changed file with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ async function migrateGlobal({
})

if (found) {
await payload.updateGlobal({
slug: global.slug,
data: document,
depth: 0,
locale: locale || undefined,
})
try {
await payload.updateGlobal({
slug: global.slug,
data: document,
depth: 0,
locale: locale || undefined,
})
// Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration
} catch (e) {
console.log('Error updating global', e, {
id: document.id,
slug: global.slug,
})
}
}
}

Expand Down Expand Up @@ -136,13 +144,21 @@ async function migrateCollection({
})

if (found) {
await payload.update({
id: document.id,
collection: collection.slug,
data: document,
depth: 0,
locale: locale || undefined,
})
try {
await payload.update({
id: document.id,
collection: collection.slug,
data: document,
depth: 0,
locale: locale || undefined,
})
// Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration
} catch (e) {
console.log('Error updating collection', e, {
id: document.id,
slug: collection.slug,
})
}
}
}
page++
Expand Down

0 comments on commit cf66341

Please sign in to comment.