You are here because of:
Cannot resolve table name close to (id) Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
What to check when you have MySQL foreign key related errors
- Table should be of same engine (InnoDB)
- Table fields should be of same type
- Pay attention to INT size and UNSIGNED
- Values inserted/updated in the main table are also present in the foreign table
- You are inserting/updating all required fields
How to debug
Execute the following SQL query:
SHOW ENGINE INNODB STATUS
and look for:
------------------------ LATEST FOREIGN KEY ERROR ------------------------
If you see:
“Cannot resolve table name close to: (id)”,
or
“Trying to add to index `fieldname` tuple: … But the parent table `dbname`.`tablename` or its .ibd file does not currently exist!”
then one of your tables is MyISAM. Convert it to InnoDB.