Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#22576 closed Bug (fixed)

makemigrations requires 'default' database configuration

Reported by: anonymous Owned by: nobody
Component: Migrations Version: 1.7-beta-2
Severity: Release blocker Keywords:
Cc: murfi Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


According to, it is OK use an empty dictionary as the 'default' entry in settins.DATABASES in a multi-database setup, but the makemigations management command insists on it being configured.

To reproduce, do "django-admin startproject mmtest", and edit the

class DbRouter(object):
   def db_for_read(self, model, **hints):
        return 'nondefault';
   db_for_write = db_for_read

DATABASE_ROUTERS = ('mmtest.settings.DbRouter', )

    'default': {},
    'nondefault': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),


(mmtest)vagrant@localhost:~/mmtest$ ./ makemigrations
Traceback (most recent call last):
  File "./", line 10, in <module>
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/core/management/", line 427, in execute_from_command_line
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/core/management/", line 419, in execute
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/core/management/", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/core/management/", line 337, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/core/management/commands/", line 56, in handle
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/db/migrations/", line 148, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/db/migrations/", line 48, in applied_migrations
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/db/migrations/", line 38, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.get_table_list(self.connection.cursor()):
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/db/backends/", line 162, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/home/vagrant/.virtualenvs/mmtest/local/lib/python2.7/site-packages/django/db/backends/dummy/", line 18, 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.

Change History (5)

comment:1 Changed 4 years ago by anonymous

Component: UncategorizedMigrations
Type: UncategorizedBug

comment:2 Changed 4 years ago by Tim Graham

Triage Stage: UnreviewedAccepted


# Load the current graph state. Takes a connection, but it's not used
# (makemigrations doesn't look at the database state).
# Also make sure the graph is built without unmigrated apps shoehorned in.
loader = MigrationLoader(connections[DEFAULT_DB_ALIAS])

The comment doesn't seem accurate given the traceback.

comment:3 Changed 4 years ago by murfi

Cc: murfi added

comment:4 Changed 4 years ago by Andrew Godwin <andrew@…>

Resolution: fixed
Status: newclosed

In f9d7e18dc5fa324ed095c6aafd83a34f3086a3de:

Fixed #22576: Ensure makemigrations doesn't touch the database.

comment:5 Changed 4 years ago by Andrew Godwin <andrew@…>

In 2afb6e0526eeffde141d7f2b81dc54df7f45f1ba:

[1.7.x] Fixed #22576: Ensure makemigrations doesn't touch the database.

Note: See TracTickets for help on using tickets.
Back to Top