New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB dumps do not disable foreign key checks #440

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

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

This comment has been minimized.

Show comment
Hide comment
@Deesen

Deesen Jan 18, 2016

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@TimGS

TimGS Jan 18, 2016

Contributor

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.

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.

dmi3yy added a commit that referenced this issue Jan 18, 2016

@Deesen

This comment has been minimized.

Show comment
Hide comment
@Deesen

Deesen Jan 18, 2016

Contributor

It is added now.

Contributor

Deesen commented Jan 18, 2016

It is added now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment