Opened 5 years ago
Last modified 5 years ago
#32264 new Cleanup/optimization
Run database checks by default in some scenarios
| Reported by: | Adam Johnson | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (System checks) | Version: | 3.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Simon Charette | Triage Stage: | Accepted |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
#31055 disabled database checks by default in order to make tests that don't set up certain databases pass. This is great but it leads to a couple problems:
- Even with
manage.py check --deployas we suggest in the deployment checklist, the database configuration checks won't be run now. - Users need to name all their database aliases on the command line if running
manage.py check. Even if--database defaultwas added to a deployment script early in the project, it's likely to be forgotten when adding a new database connection. - Database checks *are* run during
manage.py migrate, but that output can be long if several migrations are executed with a higher verbosity level, so any non-error messages are likely to be missed.
I write this as I'm trying to figure out what to do with the Django-MySQL database checks which show several warnings to users to improve their database configuration. I now realize that they will mostly be disabled for users on Django 3.1.
My suggestions would be:
- Enable
--database __all__to allow specifying all the database aliases on the command line. - Make
--deployimply--database __all__. Since this is normally run around the same time asmigrate, it shouldn't be an issue to connect to all databases at that point (and was the behaviour of Django <3.1 anyway). - Make
runserverrun database checks for all connections. This will help catch issues in development.
Note:
See TracTickets
for help on using tickets.
I wonder if we could make
--databasewithout a value alias to--database __all__instead. Maybe it's not a good idea due as might cause an issue similar to #31621?Makes sense to me.