diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2021-08-02 11:07:58 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-08-04 09:57:32 +0200 |
| commit | 910ecd1b8df7678f45c3d507dde6bcb1faafa243 (patch) | |
| tree | 7175c8df7bbfcacd2f9e0da34d8c216c253dbd54 /django | |
| parent | 202d3e193a33278311eb68f7c5727901e9b99b43 (diff) | |
Fixed #29063 -- Fixed migrate crash when specifying a name of partially applied squashed migrations.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/migrate.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py index 55b8faf38b..34fcb9bc58 100644 --- a/django/core/management/commands/migrate.py +++ b/django/core/management/commands/migrate.py @@ -140,7 +140,16 @@ class Command(BaseCommand): except KeyError: raise CommandError("Cannot find a migration matching '%s' from app '%s'." % ( migration_name, app_label)) - targets = [(app_label, migration.name)] + target = (app_label, migration.name) + # Partially applied squashed migrations are not included in the + # graph, use the last replacement instead. + if ( + target not in executor.loader.graph.nodes and + target in executor.loader.replacements + ): + incomplete_migration = executor.loader.replacements[target] + target = incomplete_migration.replaces[-1] + targets = [target] target_app_labels_only = False elif options['app_label']: targets = [key for key in executor.loader.graph.leaf_nodes() if key[0] == app_label] |
