From a374f22accdab865f4a3c84d90b23aa21a1afe76 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 19 Nov 2024 16:12:27 +0500 Subject: [PATCH] Fix migration (#7197) --- models/core/src/migration.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/models/core/src/migration.ts b/models/core/src/migration.ts index 6760afb816..36a96bafd0 100644 --- a/models/core/src/migration.ts +++ b/models/core/src/migration.ts @@ -312,13 +312,10 @@ export const coreOperation: MigrateOperation = { _class: 'core:class:TxCollectionCUD' as Ref> }) while (true) { - const txes = await iterator.next(1000) + const txes = await iterator.next(200) if (txes === null || txes.length === 0) break processed += txes.length try { - await client.deleteMany(DOMAIN_TX, { - _id: { $in: txes.map((it) => it._id) } - }) await client.create( DOMAIN_TX, txes.map((tx) => { @@ -327,10 +324,14 @@ export const coreOperation: MigrateOperation = { collection, attachedTo: objectId, attachedToClass: objectClass, - ...(tx as any).tx + ...(tx as any).tx, + objectSpace: (tx as any).tx.objectSpace ?? tx.objectClass } }) ) + await client.deleteMany(DOMAIN_TX, { + _id: { $in: txes.map((it) => it._id) } + }) } catch (err: any) { console.error(err) }