#22931: Migrations cannot rename intermediate models
-------------------------------------+-------------------------------------
     Reporter:  JockeTF              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.7-rc-2
     Severity:  Normal               |               Resolution:
     Keywords:  migrations migrate   |             Triage Stage:  Accepted
  makemigrations rename              |      Needs documentation:  0
  intermediate model                 |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by Markush2010):

 * cc: info+coding@… (added)


Comment:

 I'm not sure why there is no stable sorting on the fields in model states,
 but this fix makes rename detection more reliable:

 {{{#!patch
 diff --git a/django/db/migrations/autodetector.py
 b/django/db/migrations/autodetector.py
 index c8b7db7..441a453 100644
 --- a/django/db/migrations/autodetector.py
 +++ b/django/db/migrations/autodetector.py
 @@ -73,7 +73,7 @@ class MigrationAutodetector(object):
          change during renames)
          """
          fields_def = []
 -        for name, field in fields:
 +        for name, field in sorted(fields):
              deconstruction = self.deep_deconstruct(field)
              if field.rel and field.rel.to:
                  del deconstruction[2]['to']
 }}}

 I cannot reproduce the renaming problem on stable/1.7.x or master.

--
Ticket URL: <https://code.djangoproject.com/ticket/22931#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.66cb3583bd8b4a3c7836174c811d1d39%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to