#21961: Add support for database-level cascading options
-------------------------------------+-------------------------------------
Reporter: Christophe Pettus | Owner: Thibault
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Steven Mapes):
I hit an issue today which lead me back to this ticket. In MySQL 5.7 and 8
the default behaviour for FK constraints is RESTRICT which means that if
you create your model with an on_delete=models.CASCADE, the SQL migration
is created within the ON DELETE argument which means the table is created
using the default constraint of RESTRICT.
This means that the database will not act as intended if the models are
not deleted in the right order things break, but more over DELETE
statements directly on the database will break.
This means Django should not really be considered compatible with MySQL
5.7 or 8+ and probably older versions.
Here's the MySQL docs - https://dev.mysql.com/doc/refman/8.0/en/create-
table-foreign-keys.html#foreign-key-referential-actions
"RESTRICT: Rejects the delete or update operation for the parent table.
Specifying RESTRICT (or NO ACTION) is the same as omitting the ON DELETE
or ON UPDATE clause."
This means if you work on a project that requires actions to be taken at a
database level you have to manually drop and recreate the foreign keys
--
Ticket URL: <https://code.djangoproject.com/ticket/21961#comment:35>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/061.c9de2d3c2fe676dc571a5b6f195832d9%40djangoproject.com.