Log and display useful information when database upgrades fail.
Review Request #12507 — Created Aug. 5, 2022 and submitted
Every so often, someone encounters a bad database upgrade. This often
comes from in-house modifications, canceled upgrades, or an upgrade from
some particular versions where Django Evolution or Django had some bad
behavior in their SQL or project signature generation.To help diagnose these issues, this change logs useful information when
either the project signature diff is non-empty (indicating missing
evolution state) or an upgrade fails due to an error. The contents of
the log include:
- Any useful error messages
- A project signature diff
- Lists of applied evolutions and migrations
- Lists of pending evolutions
- The current stored signature
- Timestamps of all stored signatures
- An information (but not schema) dump of the database
Ideally we'd also log the SQL schema, but that'd require some
per-database logic for correctly running each one's SQL dumping command.
Instead, we'll leave that to something handled during support.
There are also fixes for typos in the output message, and more detail
in the upgrade failure message.
This is something I've had on the backburner for a long time, but a
recent hard-to-diagnose failure in CI helped incentivize building this
logic. Hopefully it will help in the future when customers reach out
with problems.
Simulated different failures, both at signature diff time and upgrade
time. Checked the resulting log file and the output for errors.
Summary | ID |
---|---|
c7a32399ac6b61959582f5d8d028eb2bcf46ef7d |
Description | From | Last Updated |
---|---|---|
undefined name 'get_app_label' Column: 44 Error code: F821 |
reviewbot |
- Change Summary:
-
Fixed a missing import needed for showing pending evolutions, and tested that case again.
- Commits:
-
Summary ID e8ed0e490b4c2c1eb7128de6faebb5df57c0808d c7a32399ac6b61959582f5d8d028eb2bcf46ef7d - Diff:
-
Revision 2 (+542 -16)