Integrity constraint violation: 1062 Duplicate entry '3-2-9' for key 'PRIMARY', query was: ALTER TABLE catalog_category_product_index_tmp ADD CONSTRAINT PRIMARY KEY (category_id,product_id,store_id), COMMENT='Catalog Category Product Indexer temporary table' enter image description here

this error comes when I run the setup:upgrade command in Magento 2 please make some suggestions to get rid of this error

  • can you show your schema file?
    – Mohit Rane
    Jul 18, 2019 at 9:16
  • i could not understand which file i show u..? Jul 18, 2019 at 10:40
  • installschema.php file
    – Mohit Rane
    Jul 18, 2019 at 10:57
  • please tell me which location exist this file...? Jul 18, 2019 at 11:01
  • you said error comes start of schema creation/update right? then you must be creating table right? , file will be at app/code/Vendor/Module/Setup/ folder
    – Mohit Rane
    Jul 18, 2019 at 11:35

1 Answer 1


Check-in which module has stuck the setup:upgrade and apply one of the solutions welpixel : How to fix Integrity constraint violation

or go in your database and remove the duplicated manually, following the logic @dev_67Commerce suggested : Duplicate entry - Magento 2 Ask Question,

  • error come start of schema creation/update Jul 18, 2019 at 8:59
  • i mean wich module get stucked Jul 18, 2019 at 9:16
  • see my updated question Jul 18, 2019 at 10:11
  • Follow the second link i showed to you Jul 18, 2019 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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