Modify ↓
Ticket #415 (closed defect: fixed)
adding OneToOneFields creates wrong column name
| Reported by: | Alexander Clausen <alex@…> | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 0.7.1 |
| Component: | migrations | Version: | 0.7 |
| Keywords: | Cc: |
Description
consider the following model:
class A(models.Model):
name = models.CharField(max_length=100)
class B(models.Model):
a_1 = models.OneToOneField(A, related_name="b_1")
a_2 = models.OneToOneField(A, related_name="b_2", blank=True, null=True)
where
- A was created,
- then the app was converted to south (0001),
- B was added in a migration (without a_2, 0002),
- and then a_2 was added (0003)
the resulting schema is:
sqlite> .schema footest_a
CREATE TABLE "footest_a" ("id" integer NOT NULL PRIMARY KEY, "name" varchar(100) NOT NULL);
sqlite> .schema footest_b
CREATE TABLE "footest_b" ("a_1_id" integer UNIQUE, "id" integer PRIMARY KEY, "a_2" integer NULL UNIQUE);
sqlite>
note that a_2 is missing the _id suffix, but a_1 is created allright.
Attachments
Change History
comment:1 Changed 3 years ago by Alexander Clausen <alex@…>
sorry, of course I should have mentioned that this is on SQLite using south tip
comment:3 Changed 3 years ago by carl@…
Fix for this is in my branch: http://bitbucket.org/carljm/south/changeset/898fefd63e0e
Actual fix is from patch on #424, it's a one-liner. I also fixed the add_columns test so that it fails without this; previously it never actually checked that the proper column was created, just that the add_column call completed without error.
Note: See
TracTickets for help on using
tickets.
