On Apr 30, 9:42 pm, Nick Arnett <nick.arn...@gmail.com> wrote:

> If you don't have data in the table, just drop it and use "unique_together"
> in models.py to define your composite key.  You'll find that in the Django
> docs.  Then do syncdb and Django will create the table with your composite
> key.

I don't have data.

Using "unique_together" wouldn't work because I want that composite
index to be the clustered index. It'd only be the clustered index if
it is the primary index.


> Otherwise, you can make the change in models.py, as above, and change the PK
> manually.

So changing the PK manually wouldn't break some internal Django
operations?

For example when I save() an object, Django would use the PK to check
if the object already exists or not and then decide whether to do an
insert or update. By changing the PK manually, would I break the
save() function?

Presumably I'd need to keep the Django-generated PK which is an auto-
increment, even though I have no use for it, right?

There might be other similar situations where Django is interacting
with the PK. I just wanted to make sure by changing the PK I wouldn't
be breaking things.


> If there are FKs involved, you might also want to make the appropriate
> changes if you're not re-creating all the involved tables with syncdb.

There wouldn't be FKs involved.

-- 
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