danpu icon indicating copy to clipboard operation
danpu copied to clipboard

Cannot add foreign key constraing

Open ghost opened this issue 11 years ago • 2 comments

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

ghost avatar Nov 13 '14 00:11 ghost

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");

abhishek6262 avatar Jan 19 '19 10:01 abhishek6262

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

cdjenkins avatar Jan 28 '21 08:01 cdjenkins