Implement search for rich text fields and use it for notes (#7953)
Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -11,6 +11,7 @@ import {
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { generateMigrationName } from 'src/engine/metadata-modules/workspace-migration/utils/generate-migration-name.util';
|
||||
import {
|
||||
WorkspaceMigrationColumnAction,
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationEntity,
|
||||
WorkspaceMigrationTableAction,
|
||||
@ -87,29 +88,57 @@ export class WorkspaceMigrationFieldFactory {
|
||||
): Promise<Partial<WorkspaceMigrationEntity>[]> {
|
||||
const workspaceMigrations: Partial<WorkspaceMigrationEntity>[] = [];
|
||||
|
||||
for (const fieldMetadata of fieldMetadataCollection) {
|
||||
if (fieldMetadata.type === FieldMetadataType.RELATION) {
|
||||
continue;
|
||||
}
|
||||
const fieldMetadataCollectionGroupByObjectMetadataId =
|
||||
fieldMetadataCollection.reduce(
|
||||
(result, currentFieldMetadata) => {
|
||||
result[currentFieldMetadata.objectMetadataId] = [
|
||||
...(result[currentFieldMetadata.objectMetadataId] || []),
|
||||
currentFieldMetadata,
|
||||
];
|
||||
|
||||
const migrations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: computeObjectTargetTable(
|
||||
originalObjectMetadataMap[fieldMetadata.objectMetadataId],
|
||||
),
|
||||
action: WorkspaceMigrationTableActionType.ALTER,
|
||||
columns: this.workspaceMigrationFactory.createColumnActions(
|
||||
return result;
|
||||
},
|
||||
{} as Record<string, FieldMetadataEntity[]>,
|
||||
);
|
||||
|
||||
for (const objectMetadataId in fieldMetadataCollectionGroupByObjectMetadataId) {
|
||||
const fieldMetadataCollection =
|
||||
fieldMetadataCollectionGroupByObjectMetadataId[objectMetadataId];
|
||||
|
||||
const columns: WorkspaceMigrationColumnAction[] = [];
|
||||
|
||||
const objectMetadata =
|
||||
originalObjectMetadataMap[fieldMetadataCollection[0]?.objectMetadataId];
|
||||
|
||||
for (const fieldMetadata of fieldMetadataCollection) {
|
||||
// Relations are handled in workspace-migration-relation.factory.ts
|
||||
if (fieldMetadata.type === FieldMetadataType.RELATION) {
|
||||
continue;
|
||||
}
|
||||
|
||||
columns.push(
|
||||
...this.workspaceMigrationFactory.createColumnActions(
|
||||
WorkspaceMigrationColumnActionType.CREATE,
|
||||
fieldMetadata,
|
||||
),
|
||||
},
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
workspaceMigrations.push({
|
||||
workspaceId: fieldMetadata.workspaceId,
|
||||
name: generateMigrationName(`create-${fieldMetadata.name}`),
|
||||
workspaceId: objectMetadata.workspaceId,
|
||||
name: generateMigrationName(
|
||||
`create-${objectMetadata.nameSingular}-fields`,
|
||||
),
|
||||
isCustom: false,
|
||||
migrations,
|
||||
migrations: [
|
||||
{
|
||||
name: computeObjectTargetTable(
|
||||
originalObjectMetadataMap[objectMetadataId],
|
||||
),
|
||||
action: WorkspaceMigrationTableActionType.ALTER,
|
||||
columns,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user