Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23503 closed Bug (fixed)

renaming model with self-referential ManyToManyField breaks DB schema

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: Migrations Version: 1.7
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Steps to reproduce:

  • initial models.py in test app:
from django.db import models

class Thing(models.Model):

    things = models.ManyToManyField('self')
  • do
manage.py makemigrations test
  • change model's name:
from django.db import models

class OtherThing(models.Model):

    things = models.ManyToManyField('self')
  • do
manage.py makemigrations test
manage.py migrate
  • in manage.py shell:
from test.models import OtherThing; OtherThing.things.through.objects.all()
  • last line results in:
<repr(<django.db.models.query.QuerySet at 0x7fcdea125290>) failed: django.db.utils.ProgrammingError: ОШИБКА:  колонка test_otherthing_things.from_otherthing_id не существует
LINE 1: SELECT "test_otherthing_things"."id", "test_otherthing_thing...
                                              ^
>

Change History (4)

comment:1 by Sergey Fedoseev, 10 years ago

Has patch: set

comment:2 by Tim Graham, 10 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 463952d94014ac2ea70a96828ddbf1330b504fc7:

Fixed #23503 -- Fixed renaming of model with self-referential m2m field.

comment:4 by Tim Graham <timograham@…>, 10 years ago

In 991ec655b64a6284a09117a8474026d9a75bc963:

[1.7.x] Fixed #23503 -- Fixed renaming of model with self-referential m2m field.

Backport of 463952d940 from master

Note: See TracTickets for help on using tickets.
Back to Top