Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24332 closed Bug (fixed)

Sites migration fails when DATABASES['default'] = {}

Reported by: Thomas Recouvreux Owned by: Tim Graham
Component: Migrations Version: 1.7
Severity: Release blocker Keywords: migrate post_migrate
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

On Django 1.7.4 the management command migrate --database=xxx fails when DATABASES['default'] = {} with django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details..
On Django 1.7.3 it works fine.
More details can be found on https://code.djangoproject.com/ticket/24298.

To reproduce the problem:

  1. Create a new project
  2. Edit the settings.py this way:
DATABASES = {
    'default': {},
    'mysite': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db_mysite.sqlite3'),
    }
}
  1. Run python manage.py migrate --database=mysite

Problem:
It seems Django tries to access the default connection.

I am attaching an output log of the command.
Here is a sample project to reproduce the behaviour: ​https://github.com/trecouvr/test_dj_migrate_174.

Attachments (1)

migrate_sites_failure.log (5.5 KB ) - added by Thomas Recouvreux 9 years ago.

Download all attachments as: .zip

Change History (10)

by Thomas Recouvreux, 9 years ago

Attachment: migrate_sites_failure.log added

comment:1 by Tim Graham, 9 years ago

Description: modified (diff)

This seems to be a duplicate of #24298 which was fixed (did you try this on the stable/1.7.x branch?). Markus asked you to open a new issue for create_default_site() not propagating the using parameter. Did you misunderstand him or am I misunderstanding you?

comment:2 by Thomas Recouvreux, 9 years ago

I am not sure if I misunderstood him or not, but I get the error reported on this ticket with branch stable/1.7.x and this is not exactly the same as mentioned in #24298. This looks like the same as #24298 but the root cause is not the same (The root cause of #24298 is the post_migrate call related to the 'auth' application whereas here the error is related to the 'sites' application).

comment:3 by Tim Graham, 9 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned
Triage Stage: UnreviewedAccepted

Oh, I see, will look at this.

comment:4 by Tim Graham, 9 years ago

Description: modified (diff)
Has patch: set
Needs tests: set

PR (not sure about tests at the moment)

comment:5 by Tim Graham, 9 years ago

Needs tests: unset

Tests added.

comment:6 by Tim Graham, 9 years ago

Severity: NormalRelease blocker

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In e8cf4f8abec87b9da6ed8e5c8cf833af9b27f4dd:

Fixed #24332 -- Fixed contrib.sites create_default_site() when 'default' DATABASES is empty.

comment:8 by Tim Graham <timograham@…>, 9 years ago

In 1b93b0977d2fa7d3cca2fb64168655582e7a88f9:

[1.7.x] Fixed #24332 -- Fixed contrib.sites create_default_site() when 'default' DATABASES is empty.

Backport of e8cf4f8abec87b9da6ed8e5c8cf833af9b27f4dd from master

comment:9 by Tim Graham <timograham@…>, 9 years ago

In 4c948c7c9d8b8bb4a36f703a6e96de5914740b0f:

[1.8.x] Fixed #24332 -- Fixed contrib.sites create_default_site() when 'default' DATABASES is empty.

Backport of e8cf4f8abec87b9da6ed8e5c8cf833af9b27f4dd from master

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