Qfix: consistent space/project/task type mixi ids (#5089)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-03-28 21:49:09 +04:00 committed by GitHub
parent 92d0b93692
commit 095a9b5d6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -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<Class<Doc>> = 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<Class<Doc>>
await client.createDoc(
core.class.Mixin,
core.space.Model,

View File

@ -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<Class<Doc>> = 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<Class<Doc>>
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<Class<Task>> = 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<Class<Task>>
tdata.targetClass = targetClassId
await client.createDoc(