feat: new relation sync-metadata, twenty-orm, create/update (#10217)

Fix
https://github.com/twentyhq/core-team-issues/issues/330#issue-2827026606
and
https://github.com/twentyhq/core-team-issues/issues/327#issue-2827001814

What this PR does when `isNewRelationEnabled` is set to `true`:
- [x] Drop the creation of the  foreign key as a `FieldMetadata`
- [x] Stop creating `RelationMetadata`
- [x] Properly fill `FieldMetadata` of type `RELATION` during the sync
command
- [x] Use new relation settings in TwentyORM
- [x] Properly create `FieldMetadata` relations when we create a new
object
- [x] Handle `database:reset` with new relations

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
Jérémy M
2025-04-22 19:01:39 +02:00
committed by GitHub
parent de1489aabb
commit cc29c25176
160 changed files with 3247 additions and 711 deletions

View File

@ -4,25 +4,22 @@ import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metada
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
export function isFieldMetadataOfType<
export function isFieldMetadataInterfaceOfType<
Field extends FieldMetadataInterface<FieldMetadataType>,
Type extends FieldMetadataType,
>(
fieldMetadata: Field,
type: Type,
): fieldMetadata is Field & FieldMetadataInterface<Type>;
export function isFieldMetadataOfType<
): fieldMetadata is Field & FieldMetadataInterface<Type> {
return fieldMetadata.type === type;
}
export function isFieldMetadataEntityOfType<
Field extends FieldMetadataEntity<FieldMetadataType>,
Type extends FieldMetadataType,
>(
fieldMetadata: Field,
type: Type,
): fieldMetadata is Field & FieldMetadataEntity<Type>;
export function isFieldMetadataOfType<
Field extends
| FieldMetadataInterface<FieldMetadataType>
| FieldMetadataEntity<FieldMetadataType>,
Type extends FieldMetadataType,
>(fieldMetadata: Field, type: Type): boolean {
): fieldMetadata is Field & FieldMetadataEntity<Type> {
return fieldMetadata.type === type;
}