#26930: makemigrations tries to access default databases even when set to empty
----------------------------+--------------------
Reporter: lizlemon | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26930>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.3ef0ceba853aa4b89ccbaf81f5243c32%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.