Add deletedAt to foreignKey indexes (#7133)

We had to remove soft-deletion on default filters due to the missing
indexes. We now generate composite indexes with the foreign key
containing the deletedAt column as well which should improve
performances
This commit is contained in:
Weiko
2024-09-19 11:23:40 +02:00
committed by GitHub
parent 9d5b9f8415
commit e0ada0a8ee
5 changed files with 46 additions and 9 deletions

View File

@ -38,9 +38,9 @@ export function WorkspaceIndex(
metadataArgsStorage.addIndexes({
name: `IDX_${generateDeterministicIndexName([
convertClassNameToObjectMetadataName(target.constructor.name),
propertyKey.toString(),
...[propertyKey.toString(), 'deletedAt'],
])}`,
columns: [propertyKey.toString()],
columns: [propertyKey.toString(), 'deletedAt'],
target: target.constructor,
gate,
});

View File

@ -79,6 +79,7 @@ export class EntitySchemaColumnFactory {
nullable: fieldMetadata.isNullable,
createDate: key === 'createdAt',
updateDate: key === 'updatedAt',
deleteDate: key === 'deletedAt',
array: fieldMetadata.type === FieldMetadataType.MULTI_SELECT,
default: defaultValue,
};