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:
@ -3,13 +3,11 @@ import { registerEnumType } from '@nestjs/graphql';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { RelationOnDeleteAction } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-on-delete-action.interface';
|
||||
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
|
||||
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
|
||||
|
||||
import { AGGREGATE_OPERATIONS } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
|
||||
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator';
|
||||
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
||||
@ -147,7 +145,7 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: VIEW_STANDARD_FIELD_IDS.viewFields,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`View Fields`,
|
||||
description: msg`View Fields`,
|
||||
icon: 'IconTag',
|
||||
@ -159,7 +157,7 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: VIEW_STANDARD_FIELD_IDS.viewGroups,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`View Groups`,
|
||||
description: msg`View Groups`,
|
||||
icon: 'IconTag',
|
||||
@ -171,7 +169,7 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: VIEW_STANDARD_FIELD_IDS.viewFilters,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`View Filters`,
|
||||
description: msg`View Filters`,
|
||||
icon: 'IconFilterBolt',
|
||||
@ -183,7 +181,7 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: VIEW_STANDARD_FIELD_IDS.viewFilterGroups,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`View Filter Groups`,
|
||||
description: msg`View Filter Groups`,
|
||||
icon: 'IconFilterBolt',
|
||||
@ -195,7 +193,7 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: VIEW_STANDARD_FIELD_IDS.viewSorts,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`View Sorts`,
|
||||
description: msg`View Sorts`,
|
||||
icon: 'IconArrowsSort',
|
||||
@ -207,7 +205,7 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: VIEW_STANDARD_FIELD_IDS.favorites,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Favorites`,
|
||||
description: msg`Favorites linked to the view`,
|
||||
icon: 'IconHeart',
|
||||
|
||||
Reference in New Issue
Block a user