diff --git a/models/core/src/migration.ts b/models/core/src/migration.ts index 3b51360cdd..c12addeb67 100644 --- a/models/core/src/migration.ts +++ b/models/core/src/migration.ts @@ -41,6 +41,10 @@ async function migrateSpaces (client: MigrationUpgradeClient): Promise { let updateTxes = await client.findAll(core.class.TxUpdateDoc, { objectClass: { $in: descendants }, objectId: { $nin: [...currentSpaces, ...removedSpaces] } + }, { + sort: { + modifiedOn: 1 + } }) // TXes already stored, avoid dublicate id error updateTxes = updateTxes.map((p) => { @@ -49,7 +53,9 @@ async function migrateSpaces (client: MigrationUpgradeClient): Promise { space: core.space.DerivedTx } }) - await Promise.all(updateTxes.map(async (tx) => await client.tx(tx))) + for (const tx of updateTxes) { + await client.tx(tx) + } } export const coreOperation: MigrateOperation = {