Skip to content

Fix MySQL drift with similar indexes#1904

Merged
pimeys merged 3 commits intomasterfrom
mysql-duplicate-index-bug
May 7, 2021
Merged

Fix MySQL drift with similar indexes#1904
pimeys merged 3 commits intomasterfrom
mysql-duplicate-index-bug

Conversation

@pimeys
Copy link
Copy Markdown
Contributor

@pimeys pimeys commented May 7, 2021

If the index is pointing to a same column than another index, but they
have different names, we detected drift.

Closes: prisma/prisma#6873

@pimeys pimeys added this to the 2.23.0 milestone May 7, 2021
@pimeys pimeys force-pushed the mysql-duplicate-index-bug branch from 15b36c4 to fbfb264 Compare May 7, 2021 14:01
If the index is pointing to a same column than another index, but they
have different names, we detected drift.
@pimeys pimeys force-pushed the mysql-duplicate-index-bug branch from fbfb264 to 36b868f Compare May 7, 2021 15:08
Copy link
Copy Markdown
Contributor

@tomhoule tomhoule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

let number_of_identical_indexes = self
.previous_indexes()
.filter(|right| left.column_names() == right.column_names() && left.index_type() == right.index_type())
.fold(0, |acc, _| acc + 1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a .count() method on iterators that does the same thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rust-analyzer thought not. but you're right.

@pimeys pimeys merged commit 62b5651 into master May 7, 2021
@pimeys pimeys deleted the mysql-duplicate-index-bug branch May 7, 2021 16:33
Druue pushed a commit that referenced this pull request May 24, 2024
Druue pushed a commit that referenced this pull request May 28, 2024
Druue pushed a commit that referenced this pull request May 30, 2024
Druue pushed a commit that referenced this pull request May 30, 2024
Druue added a commit that referenced this pull request May 31, 2024
* Fix drift when FKs have same columns
* Updated FK filtering to use hashset of seen fks

fixes prisma/prisma#23043
related #1904
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.

Indexing error when run migration again

2 participants