I was truncating tables like this
TRUNCATE TABLE `enterprise_url_rewrite`; -- error
TRUNCATE TABLE `enterprise_catalog_category_rewrite`; -- works fine
in that order or reversed when I got this error.
Cannot truncate a table referenced in a foreign key constraint
(`magento`.`enterprise_catalog_category_rewrite`, CONSTRAINT
`FK_415B32DA3DF924D5C803CF24EB3AC1D9` FOREIGN KEY (`url_rewrite_id`) REFERENCES
`magento`.`enterprise_url_rewrite` (`url_rewrite_id`)
I thought foreign key constraints were enforced to prevent deletion when there are actual values being referenced. I recollect (I could be wrong) being able to TRUNCATE
this table previously without disabling key checks. Note that DELETE FROM enterprise_url_rewrite
works.
More info on the constraint definition on enterprise_catalog_category_rewrite
.
KEY `FK_744D72D1D79D148B7C2542E53B0370B5` (`url_rewrite_id`),
CONSTRAINT `FK_744D72D1D79D148B7C2542E53B0370B5` FOREIGN KEY (`url_rewrite_id`)
REFERENCES `enterprise_url_rewrite` (`url_rewrite_id`) ON DELETE CASCADE ON UPDATE NO ACTION