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';
|
||||
@ -87,7 +87,7 @@ export class MessageChannelMessageAssociationWorkspaceEntity extends BaseWorkspa
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageChannel,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Message Channel Id`,
|
||||
description: msg`Message Channel Id`,
|
||||
icon: 'IconHash',
|
||||
@ -102,7 +102,7 @@ export class MessageChannelMessageAssociationWorkspaceEntity extends BaseWorkspa
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.message,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Message Id`,
|
||||
description: msg`Message Id`,
|
||||
icon: 'IconHash',
|
||||
|
||||
@ -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';
|
||||
@ -355,7 +353,7 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_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',
|
||||
@ -370,7 +368,7 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_STANDARD_FIELD_IDS.messageChannelMessageAssociations,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Message Channel Association`,
|
||||
description: msg`Messages from the channel.`,
|
||||
icon: 'IconMessage',
|
||||
@ -384,7 +382,7 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.messageFolders,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Message Folders`,
|
||||
description: msg`Message Folders`,
|
||||
icon: 'IconFolder',
|
||||
|
||||
@ -2,7 +2,8 @@ import { msg } from '@lingui/core/macro';
|
||||
import { Relation } from 'typeorm';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
|
||||
|
||||
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';
|
||||
@ -37,11 +38,12 @@ export class MessageFolderWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_FOLDER_STANDARD_FIELD_IDS.messageChannel,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Message Channel`,
|
||||
description: msg`Message Channel`,
|
||||
icon: 'IconMessage',
|
||||
inverseSideTarget: () => MessageChannelWorkspaceEntity,
|
||||
inverseSideFieldKey: 'messageFolders',
|
||||
})
|
||||
messageChannel: Relation<MessageChannelWorkspaceEntity>;
|
||||
|
||||
|
||||
@ -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';
|
||||
@ -67,7 +67,7 @@ export class MessageParticipantWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.message,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Message`,
|
||||
description: msg`Message`,
|
||||
icon: 'IconMessage',
|
||||
@ -81,7 +81,7 @@ export class MessageParticipantWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.person,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Person`,
|
||||
description: msg`Person`,
|
||||
icon: 'IconUser',
|
||||
@ -96,7 +96,7 @@ export class MessageParticipantWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.workspaceMember,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Workspace Member`,
|
||||
description: msg`Workspace member`,
|
||||
icon: 'IconCircleUser',
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
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 { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
|
||||
@ -30,7 +28,7 @@ import { MessageWorkspaceEntity } from 'src/modules/messaging/common/standard-ob
|
||||
export class MessageThreadWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_THREAD_STANDARD_FIELD_IDS.messages,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Messages`,
|
||||
description: msg`Messages from the thread.`,
|
||||
icon: 'IconMessage',
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
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';
|
||||
@ -73,7 +71,7 @@ export class MessageWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageThread,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
type: RelationType.MANY_TO_ONE,
|
||||
label: msg`Message Thread Id`,
|
||||
description: msg`Message Thread Id`,
|
||||
icon: 'IconHash',
|
||||
@ -89,7 +87,7 @@ export class MessageWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageParticipants,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Message Participants`,
|
||||
description: msg`Message Participants`,
|
||||
icon: 'IconUserCircle',
|
||||
@ -101,7 +99,7 @@ export class MessageWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageChannelMessageAssociations,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
label: msg`Message Channel Association`,
|
||||
description: msg`Messages from the channel.`,
|
||||
icon: 'IconMessage',
|
||||
|
||||
Reference in New Issue
Block a user