From 095a9b5d6ed0e65fcc5cfdca48c469699b456584 Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Thu, 28 Mar 2024 21:49:09 +0400 Subject: [PATCH] Qfix: consistent space/project/task type mixi ids (#5089) Signed-off-by: Alexey Zinoviev --- plugins/setting/src/utils.ts | 6 ++++-- plugins/task/src/utils.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/setting/src/utils.ts b/plugins/setting/src/utils.ts index 9dee5762a0..0662ab7f50 100644 --- a/plugins/setting/src/utils.ts +++ b/plugins/setting/src/utils.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import core, { Class, ClassifierKind, Data, Doc, Ref, SpaceType, TxOperations, generateId } from '@hcengineering/core' +import core, { Class, ClassifierKind, Data, Doc, Ref, SpaceType, TxOperations } from '@hcengineering/core' import { getEmbeddedLabel } from '@hcengineering/platform' export async function createSpaceType ( @@ -27,7 +27,9 @@ export async function createSpaceType ( } const baseClassClazz = client.getHierarchy().getClass(descriptorObj.baseClass) - const spaceTypeMixinId: Ref> = generateId() + // NOTE: it is important for this id to be consistent when re-creating the same + // space type with the same id as it will happen during every migration if type is created by the system + const spaceTypeMixinId = `${_id}:type:mixin` as Ref> await client.createDoc( core.class.Mixin, core.space.Model, diff --git a/plugins/task/src/utils.ts b/plugins/task/src/utils.ts index 8348649655..67e881c9f8 100644 --- a/plugins/task/src/utils.ts +++ b/plugins/task/src/utils.ts @@ -24,7 +24,6 @@ import core, { Ref, Status, TxOperations, - generateId, type AnyAttribute, type Rank, type RefTo @@ -209,7 +208,9 @@ export async function createProjectType ( const baseClassClass = client.getHierarchy().getClass(categoryObj.baseClass) - const targetProjectClassId: Ref> = generateId() + // NOTE: it is important for this id to be consistent when re-creating the same + // project type with the same id as it will happen during every migration if type is created by the system + const targetProjectClassId = `${_id}:type:mixin` as Ref> const tmpl = await client.createDoc( task.class.ProjectType, core.space.Model, @@ -324,7 +325,9 @@ async function createTaskTypes ( if (tdata.targetClass === undefined) { // Create target class for custom field. - const targetClassId: Ref> = generateId() + // NOTE: it is important for this id to be consistent when re-creating the same + // task type with the same id as it will happen during every migration if type is created by the system + const targetClassId = `${taskId}:type:mixin` as Ref> tdata.targetClass = targetClassId await client.createDoc(