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

Colliding key names #18

Open
russpoutine opened this issue Jul 31, 2012 · 0 comments
Open

Colliding key names #18

russpoutine opened this issue Jul 31, 2012 · 0 comments

Comments

@russpoutine
Copy link

Hi, I get a MySQL error (colliding index names) when trying to redefine a foreign key:

Following generated SQL fails:

ALTER TABLE `gallery_image`
DROP FOREIGN KEY `gallery_image_FK_3`
ADD CONSTRAINT `gallery_image_FK_3` FOREIGN KEY `gallery_image_FK_3` (`COLUMN_NAME`) 
REFERENCES  [more stuff here];

... with error message ...

ERROR 1005 (HY000) at line 26: Can't create table 'DATABASENAME.#sql-45c_e7' (errno: 121)

That error goes away if I split the statement in two ...

ALTER TABLE `gallery_image`
DROP FOREIGN KEY `gallery_image_FK_3`;

ALTER TABLE `gallery_image`
ADD CONSTRAINT `gallery_image_FK_3` FOREIGN KEY `gallery_image_FK_3` (`COLUMN_NAME`) 
REFERENCES  [more stuff here];

... so It seems that if both alterations are in a single statement - even though it first drops the key and then recreates it - the name still collides.

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

No branches or pull requests

1 participant