To reproduct 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'),
}
}
}}}
3. Run `python manage.py migrate --database=mysite`
Problem:
It seems Django tries to access the default connection. I found
`django.db.migrations.loader.is_latest_migration_applied` uses the default
connection.
I am attaching an output log of the command.
--
Ticket URL: <https://code.djangoproject.com/ticket/24298>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> 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.
>
> To reproduct 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'),
> }
> }
> }}}
>
> 3. Run `python manage.py migrate --database=mysite`
>
> Problem:
>
> It seems Django tries to access the default connection. I found
> `django.db.migrations.loader.is_latest_migration_applied` uses the
> default connection.
>
> I am attaching an output log of the command.
New description:
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.
To reproduct 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'),
}
}
}}}
3. Run `python manage.py migrate --database=mysite`
Problem:
It seems Django tries to access the default connection. I found
`django.db.migrations.loader.is_latest_migration_applied` uses 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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:1>
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:2>
* owner: nobody => knbk
* status: new => assigned
* easy: 0 => 1
Comment:
Seems easy enough, only 3 occurrences in the whole code-base.
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:3>
Comment (by knbk):
Patch: https://github.com/knbk/django/compare/ticket_24298
I'm not too sure on the tests, I'd like some feedback on that before I
create a pull request.
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:4>
* owner: knbk => MarkusH
Comment:
I'm about to revert the patches for
[https://code.djangoproject.com/ticket/24075#comment:10 #24075].
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
Fixed in bd3d796ecd9a66832ad26024df65caeb63b60a5d and
2832a9b028c267997b2fd3dd0989670d57cdd08f.
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:6>
Comment (by awol):
I think there is an additional failure scenario in the `Sites`
application. I haven't had the chance to track down the source of the
defect in `Sites`, in the event that I do, should I reopen this ticket or
submit a new ticket?
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:7>
Comment (by trecouvr):
Thank you for the quick updates. Following the report of awol I updated my
test project and added a log file. I found the problem might come from the
`django.contrib.sites.management.create_default_site` function which calls
`Site.objects.exists` without propagating the `using` parameter. I dont
know either if I should create a new ticket or not.
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:8>
Comment (by MarkusH):
Although it's a similar issue (missing use of `using`), it is still due to
another bug. It should be `Site.objects.using(using).exists()` in line 20.
Please open a separate issue for that.
--
Ticket URL: <https://code.djangoproject.com/ticket/24298#comment:9>