Over the past few months I’ve been porting to Django+Bootstrap a web application originally written for PHP+(huge lot of)HTML tags. The new application, when ready, validated, etc, will be put online directly on existing mySQL tables, swapping out the previous one.
Several of my tables have FK relationships as: (lines extracted with SHOW CREATE TABLE emails
);
`member_mail` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
CONSTRAINT `MadeOnAug05` FOREIGN KEY (`member_mail`) REFERENCES `user` (`mail`) ON UPDATE CASCADE,
and the meaning of this is, if field mail
in table user
is changed to something else, the mySQL daemon will automagically propagate the change to field member_mail
in table emails
. This feature works, and is of extreme utility.
When I run manage.py inspectdb it created a class containing:
member_mail = models.ForeignKey('User', models.DO_NOTHING, db_column=‘member_mail’, to_field='mail')
which seems to imply that django will NOT do the said mail change propagation, and I got worried because django documentation clears that although they seem to implement an on_delete cascade (doc wording here very poor) they offer no on_update cascade, and internet searches confirm this.
But, is this a worry at all?
The feature that I need, and uncountable database developers too, is triggered in the database itself, in the schema description: if Django changes field mail
in table user
how can the database daemon ignore the change, and DO_NOTHING instead?
My guess is, the limitation that I worry about applies only to tables created by django itself, not to others that already exist; but I am not sure.
Thank you for any insight!