Fix extra transactions during workspace upgrace (#792)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-01-11 16:12:31 +07:00 committed by GitHub
parent 7dd0aaa653
commit a973d2a0fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,12 +25,12 @@ import core from './component'
export const coreOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const ops = new TxOperations(client, core.account.System)
const targetSpaces = (await client.findAll(core.class.Space, {}))
.filter((space) => space.archived == null)
// Modify spaces by their's creators
await Promise.all(targetSpaces.map(
(space) => ops.updateDoc(space._class, space.space, space._id, { archived: false })
(space) => new TxOperations(client, space.modifiedBy).updateDoc(space._class, space.space, space._id, { archived: false })
)).catch((e) => console.error(e))
}
}