Skip to content
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

Typeorm creates migration that creates already existing unique constraint #8157

Closed
wants to merge 2 commits into from

Conversation

styczynski
Copy link

@styczynski styczynski commented Sep 6, 2021

Description of change

Fixes #8158

Typeorm was detecting whether unique constraint exists on column by using find() on all constraints for column (finding one with type UNIQUE) and then checking whether the constraint is a composite one. This is not a valid approach, because in case there's more than one constraint for a column and the first one is composite the code will not detect the column is in fact unique.

The code was adapted to use filter:

  1. Select all constraints for column with type UNIQUE
  2. Filter all composite constraints
  3. Select first result

This approach will correctly handle situation in which there are many unique keys for a column and some of them are composite and are ordered randomly.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@AlexMesser
Copy link
Collaborator

Your PR was superseded by #8364. Thank you for debugging and for contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typeorm creates migration that creates already existing unique constraint
2 participants