﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25172	System checks don't respect database routers	Ion Scerbatiuc	nobody	"We have the following database set-up:
* the default database is MySQL
* two additional databases are PostGIS

The system check framework (either `manage.py check` or `manage.py runserver`) is using the default database (mysql) to validate `django.contrib.gis.db.models.Model`-based models, and the commands are blowing up with the following error: 
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'. 

We set-up database routers for the PostGIS models to use the proper connection, but the check framework seems to ignore them. 

You can find the detailed stack trace here: https://gist.github.com/delinhabit/587d6f26afb4bbc559cb

The discussion that led to this ticket:
https://groups.google.com/forum/#!msg/django-developers/_QUT4hV43YE/b-1eTcv_5yUJ

I can try to create a PR, though I'm not sure where to start. Specifically my questions are:
* What tests case file should I extend with a regression tests? The `tests/multiple_database` doesn't test any system checks at all. `tests/system_check` could be a candidate but I need a multiple database set-up and it doesn't feel right to change that test app. Should I better create a new test app for this use case?
* I think `Field._check_backend_specific_checks` should be the place, only that at that point it already uses connection and I'm not sure how can I detect what connection should I use from the field instance (or the associated model). Should I run the Database routing code to get the connection alias? (seems a little gross to me)

Any feedback appreciated.

Thanks,
Ion
"	Bug	closed	Core (System checks)	1.7	Normal	fixed	system-checks multi-database		Ready for checkin	1	0	0	0	0	0
