#37260: AlterField changing only a Python-level on_delete option performs
unnecessary DDL
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: Bug | Status: assigned
Component: Database | Version: 6.1
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Database-level delete options, added in #21961, made an `AlterField` that
changes only the Python-level `on_delete` option of a `ForeignKey` (e.g.
`CASCADE` to `PROTECT`, or `SET_NULL` to `CASCADE`) execute real DDL. On
most backends the foreign key constraint is dropped and recreated, and on
SQLite the whole table is rebuilt. In 6.0 such migrations were database
no-ops: the `AlterField` operation was generated for state, but
`BaseDatabaseSchemaEditor._field_should_be_altered()` returned `False`, so
previously-free migrations become expensive and locking after upgrading to
6.1.
--
Ticket URL: <
https://code.djangoproject.com/ticket/37260>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.