Description
After updating Magento from the version. 2.4.2-p1 to 2.4.3 during setup:upgrade command we see below error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '106852' for key 'PRIMARY', query was: ALTER TABLE catalog_url_rewrite_product_category
ADD CONSTRAINT PRIMARY KEY (url_rewrite_id
)
The problem is this table holds around 20,000 records, and looks to be hundreds, potentially over 1000 instances of a duplicate ID for url_rewrite_id which stems from Magento 2.4.3 looking to force a primary key onto the database table catalogu_url_rewrite_product_category
Preconditions (*)
- Update Magento to version 2.4.3
- Error appears when running php bin/magento setup:upgrade command
Steps to reproduce (*)
- Error appears when running php bin/magento setup:upgrade command after changing composer.json to Magento 2.4.3 version
Expected result (*)
- Upgrade Magento to version 2.4.3 and complete setup:upgrade query
Actual result (*)
php bin/magento setup:upgrade
Cache types config flushed successfully
Cache cleared successfully
File system cleanup:
/home/storm/sites/sitename/public/generated/code/Laminas
/home/storm/sites/sitename/public/generated/code/Magento
/home/storm/sites/sitename/public/generated/code/Psr
/home/storm/sites/sitename/public/generated/code/Symfony
The directory '/home/storm/sites/sitename/public/generated/metadata/' doesn't exist - skipping cleanup
Updating modules:
Cache cleared successfully
Schema creation/updates:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '106852' for key 'PRIMARY', query was: ALTER TABLE `catalog_url_rewrite_product_category` ADD CONSTRAINT PRIMARY KEY (`url_rewrite_id`)
[ ] Severity: S0 _- Affects critical data or functionality and leaves users without workaround.
** Changing back to 2.4.2-p1 does not give this error output and setup:upgrade completes fine.