Changes between Version 1 and Version 2 of Ticket #30108, comment 11
- Timestamp:
- Nov 3, 2022, 11:52:27 AM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30108, comment 11
v1 v2 19 19 20 20 On a side note we've noticed that having the MySQL backend wrap foreign key constraint creation with `SET foreign_key_check=0` and `SET foreign_key_check=1` will allow the usage of `ALGORITHM=INPLACE` which might be a desirable behaviour to add in core since the schema editor can guarantee that no constraint violations will happen in the current session while adding the constraint. 21 22 In other words, toggling `foreign_key_check` allows for either 23 24 {{{#!sql 25 ALTER TABLE foo ADD COLUMN bar_id integer, ALGORITHM=INSTANT; 26 SET foreign_key_checks=0; 27 ALTER TABLE foo ADD CONSTRAINT bar_id_fk FOREIGN KEY foo(bar_id) REFERENCES bar(id), ALGORITM=INPLACE; 28 SET foreign_key_checks=1; 29 -- OR 30 SET foreign_key_checks=0; 31 ALTER TABLE foo ADD COLUMN bar_id integer, ADD CONSTRAINT bar_id_fk FOREIGN KEY foo(bar_id) REFERENCES bar(id), ALGORITM=INPLACE; 32 SET foreign_key_checks=1; 33 }}}