AlterField changing only a Python-level on_delete option performs unnecessary DDL
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.
Change History
(6)
| Cc: |
Mariusz Felisiak added
|
| Triage Stage: |
Unreviewed → Accepted
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
In 07d4f69: