#26930 closed Bug (fixed)
makemigrations tries to access default databases even when set to empty
| Reported by: | lizlemon | Owned by: | nobody |
|---|---|---|---|
| Component: | Migrations | Version: | 1.10 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
makemigrations always tries to access the default database, so it raises an error when settings.DATABASES 'default' key is set to empty dict. This was fixed previously in #22576, but there has been a regression.
The issue appears to be in django/core/management/commands/makemigrations.py
for db in connections:
loader.check_consistent_history(connections[db])
in settings.py:
DATABASES = {
'default': {},
'leftside': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db-left.sqlite3'),
},
'rightside': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db-right.sqlite3'),
}
}
Then create a model in an application and define a router for it, and then run manage.py makemigrations
With 1.8 and other releases this will create the migrations, but current version raises an error:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/core/management/base.py", line 356, in execute
output = self.handle(*args, **options)
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 98, in handle
loader.check_consistent_history(connections[db])
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/db/migrations/loader.py", line 276, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/db/backends/base/base.py", line 238, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/home/lemon/code/envs/dj34/lib/python3.4/site-packages/django/db/backends/dummy/base.py", line 21, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
Attachments (2)
Change History (9)
comment:1 by , 9 years ago
| Severity: | Normal → Release blocker |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Version: | master → 1.10 |
comment:3 by , 9 years ago
| Has patch: | set |
|---|
comment:5 by , 9 years ago
| Patch needs improvement: | set |
|---|
As noted on the PR, I don't using is_usable() is the best way to identify the dummy database backend.
Regression in 1.10 due to 02ae5fd31a56ffb42feadb49c1f3870ba0a24869.