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)
Magento 2.3.3 upgraded from 2.2.8
wishlist ADD CONSTRAINT WISHLIST_CUSTOMER_ID UNIQUE KEY (customer_id)Hi @nickpiro. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance - upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
@nickpiro do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop branchDetails
- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 5. Add label Issue: Confirmed once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
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.
@engcom-Bravo would I rename the wishlist table before or after the upgrade?
Also, we're using MySQL 5.6. The syntax above works for 5.7 and above!
@nickpiro
Please, try to use this query
ALTER TABLE `wishlist` CHANGE COLUMN `customer_id` `customer_id2` int unsigned default 0 not null comment 'Customer ID';
And then, try to run php bin/magento setup:upgrade
Thank you
Hey @engcom-Bravo that worked in regards to MySQL, but this is the message I received when Schema creation/updates:
Syntax error or access violation: 1061 Duplicate key name 'WISHLIST_CUSTOMER_ID', query was: ALTER TABLE wishlist ADD COLUMN customer_id int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT "Customer ID", ADD CONSTRAINT WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (customer_id) REFERENCES customer_entity (entity_id) ON DELETE CASCADE, ADD CONSTRAINT WISHLIST_CUSTOMER_ID UNIQUE KEY (customer_id)
Do you think there is something in the wishlist dbschema that causes it not to ignore the fact that the wishlist_customer_id already exists?
@nickpiro
Great that it helped.
Turned out that there has been a fix related to this behavior

This issue will not appear on Magento 2.3.4
We have to close this issue.
Thank you for collaboration
I too found those changes and made them but they did not correct the issue. I'm still receiving the duplicate key name issue.
@engcom-Bravo this issue should not be closed. I am still not able to upgrade to 2.3+ due to this issue!
It seems the setup/Schema/AddProductIdConstraint.php is not included in 2.3.4, but is in 2.3.3. There are also changes that were done to db_schema_whitelist.json but none of them seem to make a difference with my issue that I am seeing.
Should the setup/Schema/AddProductIdConstraint.php be used? Or the updates to the db_schema_whitemist.json?
I need help with this!
I think the issue lies somewhere in here:
<constraint xsi:type="foreign" referenceId="WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="wishlist"
column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id"
onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="WISHLIST_CUSTOMER_ID">
<column name="customer_id"/>
</constraint>
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.
Hi @nickpiro ,
I just stumbled upon the same error after working on a magento2.3.5 branch installing the Pearl theme and then I switched back to master branch and can not run the magento setup:upgrade because of the same error.
And in my db_schema.xml there is no record about the wishlist.
Do you have any suggestion...?
Thank you
Most helpful comment
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.