fixing index on relations (#12602)
## Why After the changes on relations, index on relations were skipped by the syncmetadata service, so no more migrations were generated for relation fields. We wanted to fix this. ## Test This PR adds unit tests for the `createIndexMigration` utility in the workspace migration builder. The tests cover: - Creating index migrations for simple fields (e.g., text fields) - Creating index migrations for relation fields (ensuring correct column naming, e.g., `authorId` for the `author` objectmetadataname) ## Excluded The delete index on relation does not need the column names so i don't think i needed to work on this method. I might be wrong. ## Checklist - [x] Added/updated unit tests for index migration creation - [x] Verified correct handling of simple and relation fields - [x] Ensured all tests pass --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -3,7 +3,7 @@ import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metad
|
||||
import { computeTableName } from './compute-table-name.util';
|
||||
|
||||
export const computeObjectTargetTable = (
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
objectMetadata: Pick<ObjectMetadataInterface, 'nameSingular' | 'isCustom'>,
|
||||
) => {
|
||||
return computeTableName(objectMetadata.nameSingular, objectMetadata.isCustom);
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@ export function isFieldMetadataInterfaceOfType<
|
||||
Field extends FieldMetadataInterface<FieldMetadataType>,
|
||||
Type extends FieldMetadataType,
|
||||
>(
|
||||
fieldMetadata: Field,
|
||||
fieldMetadata: Pick<Field, 'type'>,
|
||||
type: Type,
|
||||
): fieldMetadata is Field & FieldMetadataInterface<Type> {
|
||||
return fieldMetadata.type === type;
|
||||
@ -18,7 +18,7 @@ export function isFieldMetadataEntityOfType<
|
||||
Field extends FieldMetadataEntity<FieldMetadataType>,
|
||||
Type extends FieldMetadataType,
|
||||
>(
|
||||
fieldMetadata: Field,
|
||||
fieldMetadata: Pick<Field, 'type'>,
|
||||
type: Type,
|
||||
): fieldMetadata is Field & FieldMetadataEntity<Type> {
|
||||
return fieldMetadata.type === type;
|
||||
|
||||
Reference in New Issue
Block a user