#1820: Autogenerated ManyToMany fields can generate too long identifiers for 
mysql
to handle
---------------------------------------------------+------------------------
          Reporter:  [EMAIL PROTECTED]                |         Owner:  nobody
            Status:  new                           |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  SVN   
        Resolution:                                |      Keywords:  mysql 
             Stage:  Accepted                      |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by [EMAIL PROTECTED]):

 * cc: [EMAIL PROTECTED] (added)

Comment:

 Just ran into this.  The hash may have worked well for the constraint
 name, but they seem to vary depending on ... (?)

 ubuntu:
 ALTER TABLE `website_releasesnewsletter_additional_recipients` ADD
 CONSTRAINT
 releasesnewsletter_id_refs_abstractmailing_ptr_id_14a73856b276acd4 FOREIGN
 KEY (`releasesnewsletter_id`) REFERENCES `website_releasesnewsletter`
 (`abstractmailing_ptr_id`);

 mac:
 ALTER TABLE `website_artistnewsletter_additional_recipients` ADD
 CONSTRAINT artistnewsletter_id_refs_abstractmailing_ptr_id_4326e0be
 FOREIGN KEY (`artistnewsletter_id`) REFERENCES `website_artistnewsletter`
 (`abstractmailing_ptr_id`);

 ubuntu failed due to long-arsh identifier.

 easiest solution is to use shorter class names.
 it would be ideal to have db_table used for all related fields and
 inheritance relationships.

 example: even though AbstractMailing uses a db_table of AbsMail

 CREATE TABLE `AbsMail` (
     `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
     `subject` varchar(100) NOT NULL,
     `from_email` varchar(75) NOT NULL,
     `status` varchar(32) NOT NULL,
     `created_on` datetime NOT NULL,
     `created_by_id` integer NOT NULL,
     `sent_on` datetime NULL,
     `content_type_id` integer NULL
 )

 the subclasses still use the class name:

 CREATE TABLE `mailings_contactmailing` (
     `abstractmailing_ptr_id` integer NOT NULL PRIMARY KEY,
     `body` longtext NOT NULL
 );

 ALTER TABLE `mailings_contactmailing` ADD CONSTRAINT
 abstractmailing_ptr_id_refs_id_5468a0a0 FOREIGN KEY
 (`abstractmailing_ptr_id`) REFERENCES `AbsMail` (`id`);

-- 
Ticket URL: <http://code.djangoproject.com/ticket/1820#comment:10>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to