Morph Relations : deleteOneField (#13349)

This PR adapts teh deleteOneField to make sure morph relations can be
deleted, either
- from a relation type, 
- or from a morph relation type (which is the most obvious case).

This PR covers 
- the deletion of fieldMetadata 
- and the migrationof workspace schemas, by using the already existing
definition of relation migrations

This PR implements a new test suite: "Delete Object metadata with morph
relation" and completes the other test suites for FieldMetadata and
ObjectMetadata creation/deletion.

Last, we added a nitpick from @paul I forgot on a previous PR on
process-nested-realtion-v2

Fixes https://github.com/twentyhq/core-team-issues/issues/1197
This commit is contained in:
Guillim
2025-07-24 14:40:14 +02:00
committed by GitHub
parent 15e13b4267
commit 1ea451c8be
9 changed files with 617 additions and 57 deletions

View File

@ -4,6 +4,7 @@ import { FieldMetadataType } from 'twenty-shared/types';
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
import { RelationDTO } from 'src/engine/metadata-modules/field-metadata/dtos/relation.dto';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
export const createMorphRelationBetweenObjects = async ({
@ -51,13 +52,6 @@ export const createMorphRelationBetweenObjects = async ({
],
};
// TODO: add morphRelations to the query once available
// morphRelations {
// type
// targetFieldMetadata {
// id
// }
// }
const {
data: { createOneField: createdFieldPerson },
} = await createOneFieldMetadata({
@ -72,9 +66,20 @@ export const createMorphRelationBetweenObjects = async ({
id
nameSingular
}
morphRelations {
type
targetFieldMetadata {
id
}
targetObjectMetadata {
id
}
}
`,
expectToFail: false,
});
return createdFieldPerson as FieldMetadataEntity<FieldMetadataType.MORPH_RELATION>;
return createdFieldPerson as FieldMetadataEntity<FieldMetadataType.MORPH_RELATION> & {
morphRelations: RelationDTO[];
};
};