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:
co-authored by
Charles Bochet
Charles Bochet
parent
de1489aabb
commit
cc29c25176
+8
@@ -12,6 +12,7 @@ import { WorkflowExecutor } from 'src/modules/workflow/workflow-executor/interfa
|
||||
|
||||
import { QUERY_MAX_RECORDS } from 'src/engine/api/graphql/graphql-query-runner/constants/query-max-records.constant';
|
||||
import { GraphqlQueryParser } from 'src/engine/api/graphql/graphql-query-runner/graphql-query-parsers/graphql-query.parser';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
||||
import { ObjectMetadataItemWithFieldMaps } from 'src/engine/metadata-modules/types/object-metadata-item-with-field-maps';
|
||||
import { ObjectMetadataMaps } from 'src/engine/metadata-modules/types/object-metadata-maps';
|
||||
@@ -86,6 +87,7 @@ export class FindRecordsWorkflowAction implements WorkflowExecutor {
|
||||
|
||||
const graphqlQueryParser = new GraphqlQueryParser(
|
||||
objectMetadataItemWithFieldsMaps.fieldsByName,
|
||||
objectMetadataItemWithFieldsMaps.fieldsByJoinColumnName,
|
||||
objectMetadataMaps,
|
||||
featureFlagMaps,
|
||||
);
|
||||
@@ -120,6 +122,11 @@ export class FindRecordsWorkflowAction implements WorkflowExecutor {
|
||||
repository: WorkspaceRepository<T>,
|
||||
graphqlQueryParser: GraphqlQueryParser,
|
||||
) {
|
||||
const isNewRelationEnabled = await this.featureFlagService.isFeatureEnabled(
|
||||
FeatureFlagKey.IsNewRelationEnabled,
|
||||
objectMetadataItemWithFieldsMaps.workspaceId,
|
||||
);
|
||||
|
||||
const queryBuilder = repository.createQueryBuilder(
|
||||
workflowActionInput.objectName,
|
||||
);
|
||||
@@ -150,6 +157,7 @@ export class FindRecordsWorkflowAction implements WorkflowExecutor {
|
||||
nonFormattedObjectRecords,
|
||||
objectMetadataItemWithFieldsMaps,
|
||||
objectMetadataMaps,
|
||||
isNewRelationEnabled,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user