Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31019 closed Bug (invalid)

The database backend specific checks could be bypassed when using multiple databases.

Reported by: Shipeng Feng Owned by: nobody
Component: Core (System checks) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Shipeng Feng)

Here is the settings:

DATABASES = {
    'default': {},
    'users': {
        'NAME': 'user_data',
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'mysql_user',
        'PASSWORD': 'superS3cret'
    },
}

Here is the related source code: https://github.com/django/django/blob/f97a6123c07de5099fdf8b7d00ef7d20ed354e07/django/db/models/fields/__init__.py#L340

We only run checks for the first db, and the behavior of the first db is undetermined (the first entry of a dictionary),
if the first db is default, then we would only run dummy backend checks, mysql checks are bypassed.

Change History (5)

comment:1 by Shipeng Feng, 5 years ago

Description: modified (diff)

comment:2 by Shipeng Feng, 5 years ago

Description: modified (diff)

comment:3 by Mariusz Felisiak, 5 years ago

Resolution: invalid
Status: newclosed
Summary: The database backend specific checks could be bypassed when using multiple databases with one empty default database.The database backend specific checks could be bypassed when using multiple databases.

You're router should define allow_migrate() method that will return True only for the customer db.

Closing per TicketClosingReasons/UseSupportChannels.

comment:4 by Shipeng Feng, 5 years ago

I couldn't find any documentation for this, is this documented anywhere? Or we could add some notices about this in the documentation
so that others won't encounter the same problem.

comment:5 by Mariusz Felisiak, 5 years ago

allow_migrate() is documented also you should also read carefully the entire Multiple databases topic.

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