diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index 240abc7ca2..8a66383a51 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -24,8 +24,9 @@ import { } from '@hcengineering/model' import core, { DOMAIN_SPACE } from '@hcengineering/model-core' import tags from '@hcengineering/model-tags' -import { taskId } from '@hcengineering/task' +import { type TaskType, taskId } from '@hcengineering/task' import task from './plugin' +import { DOMAIN_TASK } from '.' /** * @public @@ -129,6 +130,18 @@ export const taskOperation: MigrateOperation = { } ) } + }, + { + state: 'fixIncorrectTaskTypeSpace', + func: async (client) => { + const taskTypes = await client.find(DOMAIN_TASK, { + _class: task.class.TaskType, + space: core.space.Model + }) + for (const taskType of taskTypes) { + await client.update(DOMAIN_TASK, { _id: taskType._id }, { $set: { space: taskType.parent } }) + } + } } ]) }, diff --git a/plugins/task/src/utils.ts b/plugins/task/src/utils.ts index 65baa57a1c..db420b1aac 100644 --- a/plugins/task/src/utils.ts +++ b/plugins/task/src/utils.ts @@ -360,7 +360,7 @@ async function createTaskTypes ( projectType: _id }) } - await client.createDoc(task.class.TaskType, core.space.Model, tdata as Data, taskId) + await client.createDoc(task.class.TaskType, _id, tdata as Data, taskId) tasksData.set(taskId, tdata as Data) _tasks.push(taskId) }