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:
+16
@@ -1,3 +1,5 @@
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
||||
import { RelationMetadataEntity } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
@@ -52,6 +54,20 @@ export type FieldComparatorResult =
|
||||
>
|
||||
| ComparatorDeleteResult<FieldMetadataEntity>;
|
||||
|
||||
export type FieldRelationComparatorResult =
|
||||
| ComparatorSkipResult
|
||||
| ComparatorCreateResult<
|
||||
Partial<ComputedPartialFieldMetadata<FieldMetadataType.RELATION>> & {
|
||||
id: string;
|
||||
}
|
||||
>
|
||||
| ComparatorUpdateResult<
|
||||
Partial<ComputedPartialFieldMetadata<FieldMetadataType.RELATION>> & {
|
||||
id: string;
|
||||
}
|
||||
>
|
||||
| ComparatorDeleteResult<FieldMetadataEntity<FieldMetadataType.RELATION>>;
|
||||
|
||||
export type RelationComparatorResult =
|
||||
| ComparatorCreateResult<Partial<RelationMetadataEntity>>
|
||||
| ComparatorDeleteResult<RelationMetadataEntity>
|
||||
|
||||
+10
-4
@@ -5,8 +5,10 @@ import { WorkspaceDynamicRelationMetadataArgsFactory } from 'src/engine/twenty-o
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
|
||||
export type PartialFieldMetadata = Omit<
|
||||
FieldMetadataInterface,
|
||||
export type PartialFieldMetadata<
|
||||
T extends FieldMetadataType = FieldMetadataType,
|
||||
> = Omit<
|
||||
FieldMetadataInterface<T>,
|
||||
'id' | 'label' | 'description' | 'objectMetadataId'
|
||||
> & {
|
||||
standardId: string;
|
||||
@@ -31,6 +33,10 @@ export type PartialComputedFieldMetadata = {
|
||||
objectMetadataId?: string;
|
||||
};
|
||||
|
||||
export type ComputedPartialFieldMetadata = {
|
||||
[K in keyof PartialFieldMetadata]: ExcludeFunctions<PartialFieldMetadata[K]>;
|
||||
export type ComputedPartialFieldMetadata<
|
||||
T extends FieldMetadataType = FieldMetadataType,
|
||||
> = {
|
||||
[K in keyof PartialFieldMetadata<T>]: ExcludeFunctions<
|
||||
PartialFieldMetadata<T>[K]
|
||||
>;
|
||||
};
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
export type UpdaterAction = 'create' | 'update' | 'delete';
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { UpdaterAction } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/updater-action.type';
|
||||
|
||||
export interface UpdaterOptions {
|
||||
actions: UpdaterAction[];
|
||||
}
|
||||
+3
@@ -1,4 +1,7 @@
|
||||
import { FeatureFlagMap } from 'src/engine/core-modules/feature-flag/interfaces/feature-flag-map.interface';
|
||||
|
||||
export interface WorkspaceSyncContext {
|
||||
workspaceId: string;
|
||||
dataSourceId: string;
|
||||
featureFlags: FeatureFlagMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user