Hello, I am new to this forum. So far I have always found help for Django problems using internet search, but this time I haven’t found anything close to my problem.
Today I noticed, that when I deploy a new version of our software to our server, the pipeline crashes due to a Django migration command. This does not happen locally, I have spend some time to test and tried to imitate the deployment procedure of the server on my local machine as much as possible, but I cannot reproduce the error locally. The weird thing is, that I even rolled back with Git to a version that was working before and the migration process still breaks.
We are using django-tenants and in the pipeline we start with a fresh database. I first execute makemigrations and everything goes fine. Then, when I run migrate, I get the following error:
File “/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py”, line 151, in handle
exit_dry = plan and options[‘check_unapplied’]
KeyError: ‘check_unapplied’
This error message comes right after I call the migrate command, there are no succeeding migrations. I’ll post the whole stack trace on the bottom.
I could not find any clue, why this is happening all of the sudden. We install our dependencies via pip and the versions are fixed, so an update of a dependency should not be the cause (Django 3.0.9, django-tenants 3.1). I looked at the code and from what I could see, the parameter should be assigned a default value from the parser, so I don’t even understand how the KeyError could be caused.
Do you have any clue what the cause could be, or maybe a hint/an idea what else I could try or look out for? Thanks
$ python3 manage.py migrate
=== Starting migration
Traceback (most recent call last):
File “manage.py”, line 16, in
execute_from_command_line(sys.argv)
File “/usr/local/lib/python3.6/site-packages/django/core/management/init.py”, line 401, in
execute_from_command_line
utility.execute()
File “/usr/local/lib/python3.6/site-packages/django/core/management/init.py”, line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/usr/local/lib/python3.6/site-packages/django/core/management/base.py”, line 330, in
run_from_argv
self.execute(*args, **cmd_options)
File “/usr/local/lib/python3.6/site-packages/django/core/management/base.py”, line 371, in execute
output = self.handle(*args, **options)
File “/usr/local/lib/python3.6/site-
packages/django_tenants/management/commands/migrate_schemas.py”, line 49, in handle
executor.run_migrations(tenants=[self.PUBLIC_SCHEMA_NAME])
File “/usr/local/lib/python3.6/site-packages/django_tenants/migration_executors/standard.py”, line 11,
in run_migrations
run_migrations(self.args, self.options, self.codename, self.PUBLIC_SCHEMA_NAME)
File “/usr/local/lib/python3.6/site-packages/django_tenants/migration_executors/base.py”, line 36, in
run_migrations
MigrateCommand(stdout=stdout, stderr=stderr).execute(*args, **options)
File “/usr/local/lib/python3.6/site-packages/django/core/management/base.py”, line 371, in execute
[ output = self.handle(*args, **options)
File “/usr/local/lib/python3.6/site-packages/django/core/management/base.py”, line 85, in wrapped
res = handle_func(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py”, line 151, in handle
exit_dry = plan and options[‘check_unapplied’]
KeyError: ‘check_unapplied’