From 899bc9eacfd26e3de230fe2f66bc960bfd595b0c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 7 Jan 2026 11:05:57 -0500 Subject: [PATCH] Batch Extra field migrations in transactions --- chrome/content/zotero/xpcom/schema.js | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index cf6653a84e..500b6dee8f 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -714,19 +714,27 @@ Zotero.Schema = new function(){ let notifierQueue = new Zotero.Notifier.Queue; try { - for (let item of items) { - let changed = item.migrateExtraFields(); - if (changed) { - await item.saveTx({ - skipDateModifiedUpdate: true, - skipSelect: true, - notifierQueue + await Zotero.Utilities.Internal.forEachChunkAsync( + items, + 100, + async function (chunk) { + await Zotero.DB.executeTransaction(async function () { + for (let item of chunk) { + let changed = item.migrateExtraFields(); + if (changed) { + await item.save({ + skipDateModifiedUpdate: true, + skipSelect: true, + notifierQueue + }); + } + if (onProgress) { + onProgress({ progress: ++progress, progressMax }); + } + } }); } - if (onProgress) { - onProgress({ progress: ++progress, progressMax }); - } - } + ); } finally { await Zotero.Notifier.commit(notifierQueue);