danpu
danpu copied to clipboard
Cannot add foreign key constraing
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
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");
You could also try to import table in a different order to see if this error doesn't happen.