Add is unique in migration v2 + refactor inferDeletionFromMissingEntities (#15070)

## Goal
- inferDeletionFromMissingEntities is now a map instead of a single
bool, allowing us to parameterise it based on the entity we want to
compare
- Adding index creation/update when field isUnique is set to true and
index deletion when isUnique is false (for now)

close https://github.com/twentyhq/core-team-issues/issues/1346
This commit is contained in:
Weiko
2025-10-15 16:08:13 +02:00
committed by GitHub
parent 7f8ec35b5d
commit c0ed246a03
29 changed files with 838 additions and 364 deletions
@@ -1,15 +1,14 @@
import { CustomException } from 'src/utils/custom-exception';
import {
appendCommonExceptionCode,
CustomException,
} from 'src/utils/custom-exception';
export class FlatEntityMapsException extends CustomException {
code: FlatEntityMapsExceptionCode;
export class FlatEntityMapsException extends CustomException<
keyof typeof FlatEntityMapsExceptionCode
> {}
constructor(message: string, code: FlatEntityMapsExceptionCode) {
super(message, code);
}
}
export enum FlatEntityMapsExceptionCode {
ENTITY_ALREADY_EXISTS = 'ENTITY_ALREADY_EXISTS',
ENTITY_NOT_FOUND = 'ENTITY_NOT_FOUND',
ENTITY_MALFORMED = 'ENTITY_MALFORMED',
}
export const FlatEntityMapsExceptionCode = appendCommonExceptionCode({
ENTITY_ALREADY_EXISTS: 'ENTITY_ALREADY_EXISTS',
ENTITY_NOT_FOUND: 'ENTITY_NOT_FOUND',
ENTITY_MALFORMED: 'ENTITY_MALFORMED',
} as const);