Ticket #402 (closed defect: fixed)
Rename of primary key on sqlite generates invalid SQL
| Reported by: | anonymous | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 0.7.1 |
| Component: | migrations | Version: | mercurial |
| Keywords: | Cc: | pjrharley@… |
Description
I'm trying to migrate from a multitable inheritance scheme to abstract inheritance through a series of steps. The first step involves changing the OneToOneField? to be just a primary key.
So I changed:
contentnode = models.IntegerField?(ContentNode?, parent_link=True, related_name="content_post")
to:
contentnode = models.IntegerField?(primary_key=True)
The migration generated automatically is attached. The error is:
"django.db.utils.DatabaseError?: table "_south_new_blog_post" has more than one primary key"
I added a print in south.db.sqlite _remake_table and the sql generated is:
CREATE TABLE "_south_new_blog_post" ("content" text, "content_parsed" text, "contentnode" integer NOT NULL PRIMARY KEY PRIMARY KEY)
Attachments
Change History
Changed 3 years ago by pjrharley@…
comment:2 Changed 3 years ago by anonymous
That patch shows you where the problem is (and actually fixes it) but I get the feeling its a case of treating a symptom and not the real problem.
comment:3 Changed 3 years ago by andrew
- Status changed from assigned to closed
- Resolution set to fixed
Your suspicion was right: the actual fix was a lot harder. Still, all done in [7d9ebddfc5ba].
