Fix migration (#7197)

This commit is contained in:
Denis Bykhov 2024-11-19 16:12:27 +05:00 committed by GitHub
parent 6292e58119
commit a374f22acc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -312,13 +312,10 @@ export const coreOperation: MigrateOperation = {
_class: 'core:class:TxCollectionCUD' as Ref<Class<Doc>> _class: 'core:class:TxCollectionCUD' as Ref<Class<Doc>>
}) })
while (true) { while (true) {
const txes = await iterator.next(1000) const txes = await iterator.next(200)
if (txes === null || txes.length === 0) break if (txes === null || txes.length === 0) break
processed += txes.length processed += txes.length
try { try {
await client.deleteMany(DOMAIN_TX, {
_id: { $in: txes.map((it) => it._id) }
})
await client.create( await client.create(
DOMAIN_TX, DOMAIN_TX,
txes.map((tx) => { txes.map((tx) => {
@ -327,10 +324,14 @@ export const coreOperation: MigrateOperation = {
collection, collection,
attachedTo: objectId, attachedTo: objectId,
attachedToClass: objectClass, 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) { } catch (err: any) {
console.error(err) console.error(err)
} }