#23556: Allow migrations to depend on a migration only part of a squashed migration -----------------------------+--------------------------------------- Reporter: Markush2010 | Owner: Markush2010 Type: Bug | Status: new Component: Migrations | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------+--------------------------------------- Changes (by carljm):
* needs_better_patch: => 0 * needs_tests: => 0 * needs_docs: => 0 * type: Uncategorized => Bug * stage: Unreviewed => Accepted Old description: > If a migration depends on another migration that is part of a squashed > migration (e.g. `6_auto` depends on `5_auto` which is part of > `3_squashed_5`) this leads to a `KeyError`: > > {{{#!python > Traceback (most recent call last): > File "/home/markus/Coding/django/django/test/utils.py", line 216, in > inner > return test_func(*args, **kwargs) > File "/home/markus/Coding/django/tests/migrations/test_loader.py", line > 263, in test_loading_squashed_complex2 > loader.build_graph() > File "/home/markus/Coding/django/django/db/migrations/loader.py", line > 233, in build_graph > self.graph.add_dependency(migration, key, parent) > File "/home/markus/Coding/django/django/db/migrations/graph.py", line > 42, in add_dependency > raise KeyError("Migration %s dependencies reference nonexistent > parent node %r" % (migration, parent)) > KeyError: "Migration migrations.6_auto dependencies reference nonexistent > parent node ('migrations', '5_auto')" > }}} > > Thus the whole idea of `squashmigrations` to be able to remove old > migrations is not really working out since a 3rd party app might depend > on a specific migration. > > I build a testcase: > https://github.com/Markush2010/django/commit/9a983d4fe66c583858eb370497d0b66227690f79 New description: If a migration depends on another migration that is part of a squashed migration (e.g. `6_auto` depends on `5_auto` which is part of `3_squashed_5`) removing the squashed migration (e.g. `5_auto`) leads to a `KeyError`: {{{#!python Traceback (most recent call last): File "/home/markus/Coding/django/django/test/utils.py", line 216, in inner return test_func(*args, **kwargs) File "/home/markus/Coding/django/tests/migrations/test_loader.py", line 263, in test_loading_squashed_complex2 loader.build_graph() File "/home/markus/Coding/django/django/db/migrations/loader.py", line 233, in build_graph self.graph.add_dependency(migration, key, parent) File "/home/markus/Coding/django/django/db/migrations/graph.py", line 42, in add_dependency raise KeyError("Migration %s dependencies reference nonexistent parent node %r" % (migration, parent)) KeyError: "Migration migrations.6_auto dependencies reference nonexistent parent node ('migrations', '5_auto')" }}} Thus the whole idea of `squashmigrations` to be able to eventually remove old migrations is not really working out since a 3rd party app might depend on a specific migration. I build a testcase: https://github.com/Markush2010/django/commit/9a983d4fe66c583858eb370497d0b66227690f79 -- -- Ticket URL: <https://code.djangoproject.com/ticket/23556#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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/069.cac5ad8f61b67e755acdc05ca47889a8%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.