On 12 Sty, 22:53, David Nolen <dnolen.li...@gmail.com> wrote:
> When migrating an existing db how do you create a proper join table
> for a ManyToMany field. I think I've got it mostly worked out except
> for the bit that looks like this in Django generated SQL:
>
> CREATE TABLE `blog_posts_authors` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `post_id` int(11) NOT NULL,
>   `user_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   UNIQUE KEY `post_id` (`post_id`,`user_id`),
>   KEY `user_id_refs_id_ea0040bf` (`user_id`) /* <========= GENERATED ?
> */
> ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
>
> Django creates some kind of random key, If I generate a random key in
> my own join table will Django automatically use this?
>

KEY is just INDEX, and AFAIK Django doesn't refer to indices anyway,
they are used internally by MySQL, to speed up queries.

By the way, South.aeracode.org is a great library for performing
migrations,
it takes care of such low-level details.

--
Tomasz Zielinski
http://pyconsultant.eu
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to