I'm trying to run the targetrule indexer in my terminal and it shows some syntax error


php indexer.php --reindex targetrule


exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (`giftease`.`enterprise_targetrule_index_crosssell_product`, CONSTRAINT `FK_94AAB744E142C77E39E72506AB13F090` FOREIGN KEY (`targetrule_id`) REFERENCES `giftease`.`enterprise_targetrule_index_cr)' in /var/www/html/giftease-upgrade/lib/Zend/Db/Statement/Pdo.php:243

I've tried this:

TRUNCATE enterprise_targetrule_index_crosssell_product;

With no success


It's better to

  1. Remove existing constraints
  2. Perform TRUNCATE operation(s)
  3. Manually delete rows that now have references to "nowhere", i.e. non-existent relations
  4. Re-create constraints

rather than disabling foreign key checks as you might run into data integrity issues.

  • the table already empty only – Ramki Aug 31 '15 at 10:29
  • Sorry, but I don't get what you are trying to say. Did it work for you? – mkerstner Aug 31 '15 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.