-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unique index created twice #7718
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request addresses an issue with duplicate unique index creation in TypeORM by modifying the handling of unique constraints in composite columns and workspace migrations.
- Modified
CompositeColumnActionFactory
to correctly setisUnique
property for composite field columns based on bothalteredFieldMetadata.isUnique
andalteredProperty.isIncludedInUniqueConstraint
- Commented out
isUnique
property inWorkspaceMigrationRunnerService
when creating columns to prevent redundant index creation - These changes aim to resolve the problem of double index creation while maintaining existing functionality for unique constraints
- The modifications may have implications on existing migrations and unique constraint management throughout the system
- Future consideration: potentially moving unique constraint handling to the field level in a later step
2 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
isUnique: | ||
(alteredFieldMetadata.isUnique && | ||
alteredProperty.isIncludedInUniqueConstraint) ?? | ||
false, | ||
defaultValue: serializedDefaultValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This change ensures that isUnique is only set when both the field is unique and the specific property is included in the unique constraint. Make sure this logic is consistent with the intended behavior for composite fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I think you can put back the index decorator in person entity? 🙂 @FelixMalfait |
isUnique
was passed to TypeORM's column creation API resulting in double index creation because it's already done via the decorator and then inWorkspaceMigrationIndexFactory
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