Skip to content
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

Cannot add foreign key constraing #18

Open
ghost opened this issue Nov 13, 2014 · 2 comments
Open

Cannot add foreign key constraing #18

ghost opened this issue Nov 13, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 13, 2014

Importing exported database on the exact same mysql database via danpu Export,

following exception thrown

Caught exception: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

@abhishek6262
Copy link

abhishek6262 commented Jan 19, 2019

You can resolve this error by disabling the foreign and unique key checks in the Dump instance while exporting the database.

$dump = new Dump;
$dump ->disableForeignKeyChecks(true) ->disableUniqueKeyChecks(true) ->file("database.sql") ->dsn($DSN) ->user($DATABASE_USER) ->pass($DATABASE_PASS) ->tmp("path/to/temp");

@cdjenkins
Copy link

You could also try to import table in a different order to see if this error doesn't happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants