Opened 10 years ago

Last modified 5 months ago

#23790 closed Bug

Possible bad interaction between migration dependencies and relabeling apps — at Version 1

Reported by: Aymeric Augustin Owned by: nobody
Component: Documentation Version: 1.7
Severity: Normal Keywords:
Cc: info+coding@…, Ryan Cheley Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Markus Holtermann)

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.

Change History (1)

comment:1 by Markus Holtermann, 10 years ago

Cc: info+coding@… added
Description: modified (diff)

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:

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

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.

Last edited 10 years ago by Markus Holtermann (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top