Open CelestialGuru opened 3 years ago
Looks like this app is not working . i am seeing same issue
Hello @CelestialGuru @pupattan
Thanks for trying out my package! Indeed so far it was only tested with only one (big) codebase.
So the way it worked for us is that only those apps are listed which we control ourselves and not django core apps or other dependencies. In particular those apps must not be in the list: accounts admin authtoken contenttypes sessions token. (Because you can not replace migrations of those. Not managed by you)
Crafting the app-list manually is a good way to go.
Can you confirm that the command also fails with only your apps? Would you see the same error then or a different?
Best, Felix
Same issue :(
Confirming the same issue on Django 5:
$ ./manage.py makemigrations --replace-all --name replace my_custom_app
Traceback (most recent call last):
File "/home/docker/code/./manage.py", line 28, in <module>
execute_from_command_line(sys.argv)
File "/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/django_replace_migrations/management/commands/makemigrations.py", line 154, in handle
loader.project_state(),
^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/django/db/migrations/loader.py", line 361, in project_state
return self.graph.make_state(
^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/django/db/migrations/graph.py", line 329, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
~~~~~~~~~~^^^^^^
KeyError: ('my_custom_app', '0001_squash')
I'm unable to follow the step where I
makemigrations --replace-all
.Steps I took
Created a new branch, deleted ALL migrations and committed changes.
Created another branch. Used:
Ran
All at once:
Error
The previous script is only for convenience. I manually wrote out the makemigrations line with all the app listed and I still got the same error. I removed each app that the key error was complaining about until I was down to like three apps before it happily ran.
Other strategies attempted
Even if I add
if model._meta.app_label not in {'admin', 'auth', 'authtoken', 'contenttypes', 'sessions', 'token'}
filter (apps which are not mine) I still get a KeyError, just with a different app.Many of my apps depend on other apps, and many of those apps depend on each other. Do I need to separate squashing into separate groups/batches? How would I tell which apps go in which group/batch?
Versions
Python: 3.6.8 Django: 2.2.1 django-replace-migrations: 0.0.2