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:
@ -1,9 +1,9 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
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 { RelationMetadataType } 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';
|
||||
@ -51,7 +51,7 @@ export class CalendarChannelEventAssociationWorkspaceEntity extends BaseWorkspac
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
CALENDAR_CHANNEL_EVENT_ASSOCIATION_STANDARD_FIELD_IDS.calendarChannel,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Channel ID`,
|
||||
description: msg`Channel ID`,
|
||||
icon: 'IconCalendar',
|
||||
@ -66,7 +66,7 @@ export class CalendarChannelEventAssociationWorkspaceEntity extends BaseWorkspac
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
CALENDAR_CHANNEL_EVENT_ASSOCIATION_STANDARD_FIELD_IDS.calendarEvent,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Event ID`,
|
||||
description: msg`Event ID`,
|
||||
icon: 'IconCalendar',
|
||||
|
||||
@ -3,12 +3,10 @@ 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 {
|
||||
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';
|
||||
@ -303,7 +301,7 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.connectedAccount,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Connected Account`,
|
||||
description: msg`Connected Account`,
|
||||
icon: 'IconUserCircle',
|
||||
@ -318,7 +316,7 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
CALENDAR_CHANNEL_STANDARD_FIELD_IDS.calendarChannelEventAssociations,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Calendar Channel Event Associations`,
|
||||
description: msg`Calendar Channel Event Associations`,
|
||||
icon: 'IconCalendar',
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
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 { RelationMetadataType } 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';
|
||||
@ -105,7 +105,7 @@ export class CalendarEventParticipantWorkspaceEntity extends BaseWorkspaceEntity
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: CALENDAR_EVENT_PARTICIPANT_STANDARD_FIELD_IDS.calendarEvent,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Event ID`,
|
||||
description: msg`Event ID`,
|
||||
icon: 'IconCalendar',
|
||||
@ -119,7 +119,7 @@ export class CalendarEventParticipantWorkspaceEntity extends BaseWorkspaceEntity
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: CALENDAR_EVENT_PARTICIPANT_STANDARD_FIELD_IDS.person,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Person`,
|
||||
description: msg`Person`,
|
||||
icon: 'IconUser',
|
||||
@ -134,7 +134,7 @@ export class CalendarEventParticipantWorkspaceEntity extends BaseWorkspaceEntity
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: CALENDAR_EVENT_PARTICIPANT_STANDARD_FIELD_IDS.workspaceMember,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Workspace Member`,
|
||||
description: msg`Workspace Member`,
|
||||
icon: 'IconUser',
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
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 { LinksMetadata } from 'src/engine/metadata-modules/field-metadata/composite-types/links.composite-type';
|
||||
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';
|
||||
@ -151,7 +149,7 @@ export class CalendarEventWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
CALENDAR_EVENT_STANDARD_FIELD_IDS.calendarChannelEventAssociations,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Calendar Channel Event Associations`,
|
||||
description: msg`Calendar Channel Event Associations`,
|
||||
icon: 'IconCalendar',
|
||||
@ -164,7 +162,7 @@ export class CalendarEventWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: CALENDAR_EVENT_STANDARD_FIELD_IDS.calendarEventParticipants,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Event Participants`,
|
||||
description: msg`Event Participants`,
|
||||
icon: 'IconUserCircle',
|
||||
|
||||
Reference in New Issue
Block a user