#23790: Possible bad interaction between migration dependencies and relabeling 
apps
-------------------------------+--------------------------------------
     Reporter:  aaugustin      |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  1.7
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by MarkusH):

 * cc: info+coding@… (added)


Old description:

> As far as I can tell, in migrations, `dependencies` is a list of
> `(app_label, migration_name)`.
>
> I'm wondering what happens if one relabels an application with
> `AppConfig.label`. How can migrations handle this case?
>
> (I haven't tried to create such a problem. I'm just making a note before
> I forget.)

New description:

 As far as I can tell, in migrations, `dependencies` is a list of
 `(app_label, migration_name)`.

 I'm wondering what happens if one relabels an application with
 `AppConfig.label`. How can migrations handle this case?

 (I haven't tried to create such a problem. I'm just making a note before I
 forget.)

 The only way I can think of is using the `appconfig.name` attribute
 instead of `appconfig.label`. But that's hard to find a smooth migration
 path.

--

Comment:

 It partially works. If there are no migrations for an app yet, all
 migrations will be created with the changed label in the dependencies and
 all places it's being referenced. But as soon as you already have existing
 migrations and then change the label of an app, the `makemigrations`
 command blows up with:

 {{{#!python
 Traceback (most recent call last):
   File "manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File "/home/markus/Coding/django/django/core/management/__init__.py",
 line 338, in execute_from_command_line
     utility.execute()
   File "/home/markus/Coding/django/django/core/management/__init__.py",
 line 330, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/markus/Coding/django/django/core/management/base.py", line
 390, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/home/markus/Coding/django/django/core/management/base.py", line
 442, in execute
     output = self.handle(*args, **options)
   File
 "/home/markus/Coding/django/django/core/management/commands/makemigrations.py",
 line 58, in handle
     loader = MigrationLoader(None, ignore_no_migrations=True)
   File "/home/markus/Coding/django/django/db/migrations/loader.py", line
 48, in __init__
     self.build_graph()
   File "/home/markus/Coding/django/django/db/migrations/loader.py", line
 295, in build_graph
     _reraise_missing_dependency(migration, parent, e)
   File "/home/markus/Coding/django/django/db/migrations/loader.py", line
 265, in _reraise_missing_dependency
     raise exc
   File "/home/markus/Coding/django/django/db/migrations/loader.py", line
 291, in build_graph
     self.graph.add_dependency(migration, key, parent)
   File "/home/markus/Coding/django/django/db/migrations/graph.py", line
 47, in add_dependency
     parent
 django.db.migrations.graph.NodeNotFoundError: Migration testapp.0002_proxy
 dependencies reference nonexistent parent node ('otherapp',
 '0001_initial')
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23790#comment:1>
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/067.741595aea655c255700ae4a16bdfb8cf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to