1

I am facing strange issue on the Magento 2.4

I have upgraded my Magento store to the latest version, and after the upgrade, I am facing one strange issue while running upgrade command.

It's looks like Magento default issue.

SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'WISHLIST_CUSTOMER_ID', query was: ALTER TABLE `wishlist` ADD CONSTRAINT `WISHLIST_CUSTOMER_ID` UNIQUE KEY (`customer_id`)

enter image description here

Magento is going to add the foreign key in the wishlist table, but that key already exists, so as per the common logic, it should be skipped, but that is not happening and it's throwing error.

enter image description here

Apart from the above issue, I have found solution for it on stackexchange but that is not a correct way.

setup:upgrade SQL error after update from 2.2.8 to 2.3.1

1 Answer 1

1

You need to remove duplicate customer_id in wishlist table

List duplicate customer_id

SELECT 
    customer_id, 
    COUNT(customer_id)
FROM
    wishlist
GROUP BY customer_id
HAVING COUNT(customer_id) > 1;

Remove them

DELETE FROM wishlist WHERE wishlist_id in (...);
1
  • 1
    My wishlist table is already empty so this is not an solution. Dec 15, 2022 at 9:45

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.