Alexis Smirnov wrote:
> ALTER TABLE `console_restoreevent` ADD CONSTRAINT
> `identity_id_referencing_console_identity_id` FOREIGN KEY (`identity_i
> d`) REFERENCES `console_identity` (`id`);
> ALTER TABLE `console_backupevent` ADD CONSTRAINT
> `identity_id_referencing_console_identity_id` FOREIGN KEY (`identity_id
> `) REFERENCES `console_identity` (`id`);
> COMMIT;
>
> Questions:
>  - Any idea why MySQL 5.0.20-nt does't like above SQL?
>  - Is it a good idea to try to create SQL that respects the order of classes
> within .py file (thus avoiding ALTER TABLE)
>  - If so, do you think the fix above is the right one?

MySQL requires each constraint to have the same name. If you have two
FK fields to the same model, with the same name, the current naming
scheme will generate the same exact constraint name. That's what the
cryptic MySQL error is about (both of your constraints are named
`identity_id_referencing_console_identity_id`). It seems an easy fix
would be to add the referencing table name to the constraint name but
there are 64-character limits to these names in MySQL. In fact, I think
it used to work that way and was changed to work around the length
problem, which now triggers a new one.

Here is the old thread with some references to relevant tickets and a
link to the MySQL bug report:
http://groups.google.com/group/django-developers/browse_thread/thread/103d6c504f78d59d/db4d115ddb175d27?q=syncdb&lnk=gst&rnum=1#db4d115ddb175d27

A simple workaround is to name the field differently in each class
(e.g. identity and ident).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to