diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index 03c06f7c69..259d456fc0 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -572,6 +572,37 @@ export const taskOperation: MigrateOperation = { { state: 'migrateRanks', func: migrateRanks + }, + { + state: 'migrate_wrong_isdone', + func: async (client: MigrationClient) => { + const statuses = client.model.findAllSync(core.class.Status, { + category: { $in: [task.statusCategory.Won, task.statusCategory.Lost] } + }) + + await client.update( + DOMAIN_TASK, + { + _class: { $in: client.hierarchy.getDescendants(task.class.Task) }, + status: { $in: statuses.map((it) => it._id) }, + isDone: false + }, + { + isDone: true + } + ) + await client.update( + DOMAIN_TASK, + { + _class: { $in: client.hierarchy.getDescendants(task.class.Task) }, + status: { $nin: statuses.map((it) => it._id) }, + isDone: true + }, + { + isDone: false + } + ) + } } ]) },