Fix unique index created twice (#7718)
`isUnique` was passed to TypeORM's column creation API resulting in double index creation because it's already done via the decorator and then in `WorkspaceMigrationIndexFactory` It would be interesting to move it at this field level in a later step, which is why I also fixed `CompositeColumnActionFactory` to pass isUnique on the correct columns, even though it's being ignored later on
This commit is contained in:
@ -183,7 +183,10 @@ export class CompositeColumnActionFactory extends ColumnActionAbstractFactory<Co
|
||||
enum: enumOptions,
|
||||
isNullable:
|
||||
alteredFieldMetadata.isNullable || !alteredProperty.isRequired,
|
||||
isUnique: alteredFieldMetadata.isUnique ?? false,
|
||||
isUnique:
|
||||
(alteredFieldMetadata.isUnique &&
|
||||
alteredProperty.isIncludedInUniqueConstraint) ??
|
||||
false,
|
||||
defaultValue: serializedDefaultValue,
|
||||
isArray:
|
||||
alteredProperty.type === FieldMetadataType.MULTI_SELECT ||
|
||||
|
||||
@ -402,7 +402,10 @@ export class WorkspaceMigrationRunnerService {
|
||||
enumName: enumName,
|
||||
isArray: migrationColumn.isArray,
|
||||
isNullable: migrationColumn.isNullable,
|
||||
isUnique: migrationColumn.isUnique,
|
||||
/* For now unique constraints are created at a higher level
|
||||
as we need to handle soft-delete and a bug on empty strings
|
||||
*/
|
||||
// isUnique: migrationColumn.isUnique,
|
||||
asExpression: migrationColumn.asExpression,
|
||||
generatedType: migrationColumn.generatedType,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user