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

Avoid creating clashing index names #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davel
Copy link

@davel davel commented Dec 12, 2019

This is to resolve a problem in which a CREATE TABLE is generated that MySQL rejects with a duplicate key name error.

When we create a foreign key constraint for MySQL we also create an index if there is not already an index beginning with the field in question. UNIQUEness constraints are implemented by indices, and so we can skip adding an index if one already exists.

To avoid changing existing working schemas, this change only skips index creation if one with the same name already exists. This case currently fails with a duplicate key error in MySQL, eg.,

ERROR 1061 (42000): Duplicate key name 'foo'

@mohawk2
Copy link
Contributor

mohawk2 commented Feb 28, 2020

This probably wants a rebase / force-push for updated CI?

@davel davel changed the base branch from master to travis March 27, 2020 16:11
@davel davel changed the base branch from travis to master March 27, 2020 16:12
@davel
Copy link
Author

davel commented Mar 27, 2020

This probably wants a rebase / force-push for updated CI?

Thank you, done. Travis now looks happy.

@mohawk2
Copy link
Contributor

mohawk2 commented Mar 28, 2020

Could you rebase it rather than that merge commit? :-)

When we create a foreign key constraint for MySQL we also create an
index, if there is not already an index beginning with the field in
question. UNIQUEness constaint are implemented by indices, and so we
should also skip adding an index if one already exists.

To avoid changing existing fully-working schemas, this change only skips
index creation if one with the same name already exists. This case
currently fails with a duplicate key error in MySQL, eg.,

    ERROR 1061 (42000): Duplicate key name 'foo'
@davel davel force-pushed the davel/clashing-index-names branch from 5a5abaf to 5a278bb Compare April 8, 2020 10:51
@davel
Copy link
Author

davel commented Apr 8, 2020

Could you rebase it rather than that merge commit? :-)

Now rebased against current master.

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.

None yet

2 participants