DB dumps do not disable foreign key checks #440

Closed
TimGS opened this Issue Oct 7, 2015 · 3 comments

Projects

None yet

3 participants

@TimGS
Contributor
TimGS commented Oct 7, 2015

The DB dumps created by the backup tool do not disable foreign key checks.

As such, the SQL files created will often fail on import if foreign keys exist in the relevant (custom) tables.

-- Tim.

@Deesen
Contributor
Deesen commented Jan 18, 2016

Is it just about adding a "SET FOREIGN_KEY_CHECKS=0;" before the DROP-Statements and "SET FOREIGN_KEY_CHECKS=1;" after them? Or is the solution more complicated?

http://stackoverflow.com/questions/3476765/mysql-drop-all-tables-ignoring-foreign-keys

@TimGS
Contributor
TimGS commented Jan 18, 2016

I think that should be fine.

If you look at an SQL dump produced by mysqldump you will see it saves the original FOREIGN_KEY_CHECKS setting instead of assuming it was 1.

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0

and at the end...

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS

-- Tim.

@Deesen
Contributor
Deesen commented Jan 18, 2016

It is added now.

@yama yama closed this Mar 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment