Magento 2.4.3 upgrade – fix Integrity constraint violation: 1062 Duplicate entry for key ‘PRIMARY’, query was: ALTER TABLE `catalog_url_rewrite_product_category` ADD CONSTRAINT PRIMARY KEY (`url_rewrite_id`) – error message on setup:upgrade


Hi there,

If you are trying to update your store the last Magento version (once this post was written 2.4.3 is latest), and you are getting the following error message:


Then this is because you are having duplicated url rewrites on your database. So, to solve this out, you will need to remove those useless and duplicated entries. To reach this out successfully, i suggest performing the following steps gettng logged into your database:


Hope this help.

Enjoy.