Ticket #402 (closed defect: fixed)

Opened 6 years ago

Last modified 4 years ago

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


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


0002_auto__chg_field_post_contentnode__chg_field_bookmark_contentnode.py (11.1 KB) - added by pjrharley@… 6 years ago.
south-primary-key-sqlite-patch.patch (526 bytes) - added by anonymous 6 years ago.

Change History

comment:1 Changed 6 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 0.7.1

Changed 6 years ago by anonymous

comment:2 Changed 6 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 6 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].

Note: See TracTickets for help on using tickets.