magento2: M2.2.8 to M2.3.3 Upgrade Wishlist Duplicate Key Name

Attempting to upgrade our Magento 2.2.8 to 2.3.3 yields various errors. When running setup:upgrade, this SQL error pops up: 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)

Preconditions (*)

Magento 2.3.3 upgraded from 2.2.8

Steps to reproduce (*)

  1. Backup composer.json file: cp composer.json composer.json.bak
  2. composer require magento/product-community-edition=2.3.3 --no-update
  3. composer require --dev allure-framework/allure-phpunit:~1.2.0 friendsofphp/php-cs-fixer:~2.14.0 lusitanian/oauth:~0.8.10 magento/magento-coding-standard:~3.0.0 magento/magento2-functional-testing-framework:2.4.5 pdepend/pdepend:2.5.2 phpmd/phpmd:@stable phpunit/phpunit:~6.5.0 sebastian/phpcpd:~3.0.0 squizlabs/php_codesniffer:~3.4.0 --sort-packages --no-update
  4. composer remove --dev sjparkinson/static-review fabpot/php-cs-fixer --no-update
  5. composer update
  6. php bin/magento cache:clean
  7. Manually clean var/cache, var/page_cache, generated/code/*
  8. php bin/magento setup:upgrade

Expected result (*)

  1. Magento install, minimal issues.

Actual result (*)

  1. When running setup:upgrade, this SQL error pops up: 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)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I recently upgraded my store from Magento 2.3.5p1 to 2.4.1. I had also removed WeltPixel’s Pearl theme. At least, I thought it was completely removed. During the upgrade, while running “php bin/magento setup:upgrade”, I encountered the error -

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)

I traced it back to this module - WeltPixel_AdvancedWishlist. Try disabling it first - “php bin/magento module:disable WeltPixel_AdvancedWishlist” and then rerun your upgrade.

Just for anyone else who has this issue: I’ve been able to resolve it by removing the following from the db_schema.xml <constraint xsi:type="unique" referenceId="WISHLIST_CUSTOMER_ID"> <column name="customer_id"/> </constraint>

Also, the setup/Schema/AddProductIdConstraint.php is not used in 2.3.0.

Hello @nickpiro

Thank you for your report.

We had similar issues reported before. It is not always reproducible, that is why we can’t start fixing it. I’m not able to reproduce this issue now.

I can offer you a workaround that should help. Rename the existing index for the wishlist table in your database: alter table wishlist rename index WISHLIST_CUSTOMER_ID to WISHLIST_CUSTOMER_ID_2;

and perform php bin/magento setup:upgrade

Please, let us know if it helped.

Thank you in advance.