#36168: migration plan in the context of squashmigrations has too many leaves
------------------------------------+--------------------------------------
Reporter: Klaas van Schelven | Owner: (none)
Type: Uncategorized | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Comment (by Klaas van Schelven):
ok, finally found a clean reproducer!
https://github.com/vanschelven/squashwithrename
{{{
(freshdjango) klaas@pop-os:~/dev/squashwithrename$ rm db.sqlite3
(freshdjango) klaas@pop-os:~/dev/squashwithrename$ python manage.py
migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, squashme,
triggerfailingcode
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
Applying squashme.0001_initial... OK
Applying
squashme.0002_rename_name_foo_rename_squashed_0003_foo_another_field... OK
Applying triggerfailingcode.0001_squashed_0002_baz_baz... OK
(freshdjango) klaas@pop-os:~/dev/squashwithrename$ python manage.py
migrate triggerfailingcode 0001_initial
Operations to perform:
Target specific migration: 0001_initial, from triggerfailingcode
Traceback (most recent call last):
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/db/migrations/state.py", line 297, in rename_field
found = fields.pop(old_name)
KeyError: 'name'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/datacrypt/dev/squashwithrename/manage.py", line 22, in
<module>
main()
File "/mnt/datacrypt/dev/squashwithrename/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/core/management/__init__.py", line 442, in
execute_from_command_line
utility.execute()
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/core/management/commands/migrate.py", line 302, in handle
pre_migrate_state =
executor._create_project_state(with_applied_migrations=True)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/db/migrations/executor.py", line 91, in
_create_project_state
migration.mutate_state(state, preserve=False)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/db/migrations/migration.py", line 91, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/db/migrations/operations/fields.py", line 303, in
state_forwards
state.rename_field(
File "/tmp/freshdjango/lib/python3.10/site-
packages/django/db/migrations/state.py", line 299, in rename_field
raise FieldDoesNotExist(
django.core.exceptions.FieldDoesNotExist: squashme.foo has no field named
'name'
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/36168#comment:2>