You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Copy To: fails on foreign key constraints (no FK_CHECKS disable, alphabetical table order) + very slow compare phase #3858
Copy To from a remote MySQL database to a local one (Structure and data, Replace existing, 100 of 100 tables) fails on foreign keys:
buildings: [1452] Cannot add or update a child row: a foreign key constraint fails
(`regest`.`buildings`, CONSTRAINT `buildings_residence_id_foreign`
FOREIGN KEY (`residence_id`) REFERENCES `estates` (`id`) ON DELETE CASCADE)
(SQLSTATE: 23000)
Result: "Copy finished with errors - 99 objects, 178 rows". The structure is created, almost no data is copied.
Cause
The structure phase already turned foreign key checks off, but the data phase did not. Tables are copied in name order with checks on, so a child written before its parent fails.
Fixed
#3859 runs the data phase with the target's foreign key checks off, on the connection that writes the rows, and restores them before the connection returns to the pool (same idea as mysqldump). It uses each driver's own disable and enable statements. Covered by a test that fails without the change.
Not tried against a live MySQL server yet.
Still open
The compare phase is very slow on a database of this size.
Tables are not ordered by foreign key dependency (parents first).
No option to continue on error instead of stopping the whole data copy.
Optional checkbox "Disable foreign key checks during copy".
Related feature request
A one-click "Copy to..." from remote to local, as other clients offer.
Activity