Changes between Version 1 and Version 2 of Ticket #30108, comment 11


Ignore:
Timestamp:
Nov 3, 2022, 11:52:27 AM (18 months ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30108, comment 11

    v1 v2  
    1919
    2020On 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
     22In other words, toggling `foreign_key_check` allows for either
     23
     24{{{#!sql
     25ALTER TABLE foo ADD COLUMN bar_id integer, ALGORITHM=INSTANT;
     26SET foreign_key_checks=0;
     27ALTER TABLE foo ADD CONSTRAINT bar_id_fk FOREIGN KEY foo(bar_id) REFERENCES bar(id), ALGORITM=INPLACE;
     28SET foreign_key_checks=1;
     29-- OR
     30SET foreign_key_checks=0;
     31ALTER TABLE foo ADD COLUMN bar_id integer, ADD CONSTRAINT bar_id_fk FOREIGN KEY foo(bar_id) REFERENCES bar(id), ALGORITM=INPLACE;
     32SET foreign_key_checks=1;
     33}}}
Back to Top