Magento 2 - 违反完整性约束:1062 重复条目 - 从社区升级到企业后 setup:upgrade 出错
Magento 2 - Integrity constraint violation: 1062 Duplicate entry - Error in setup:upgrade after upgrade from community to enterprise
我通过 composer 升级到企业版 2.3.5-p1。
现在我在执行 bin/magento setup:upgrade
:
后得到这个错误
...
Module 'Magento_GiftMessage':
Module 'Magento_GiftMessageStaging':
Module 'Magento_UrlRewrite':
Module 'Magento_GiftWrapping':
Unable to apply data patch Magento\GiftWrapping\Setup\Patch\Data\GiftOptionsAttributes for module Magento_GiftWrapping. Original exception message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9-Gift Options' for key 'EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME', query was: INSERT INTO `eav_attribute_group` (`attribute_set_id`, `attribute_group_name`, `sort_order`, `attribute_group_code`) VALUES (?, ?, ?, ?)
我在 phpMyAdmin 的搜索功能中搜索了 9-Gift Options,但我得到了 0 个结果。
我该如何解决这个问题?
我不得不在 phpmyadmin 中打开 table "eav_attribute_group"。然后我选择了 "Structure" 并查看了 "Indizes":
如您所见,EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME 设置为唯一,并使用 attribute_set_id 列构建 - attribute_group_name.
所以我搜索了重复键并将其删除:
SELECT * FROM `eav_attribute_group` WHERE `attribute_set_id` = 9 AND `attribute_group_name` = "Gift Options"
我通过 composer 升级到企业版 2.3.5-p1。
现在我在执行 bin/magento setup:upgrade
:
...
Module 'Magento_GiftMessage':
Module 'Magento_GiftMessageStaging':
Module 'Magento_UrlRewrite':
Module 'Magento_GiftWrapping':
Unable to apply data patch Magento\GiftWrapping\Setup\Patch\Data\GiftOptionsAttributes for module Magento_GiftWrapping. Original exception message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9-Gift Options' for key 'EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME', query was: INSERT INTO `eav_attribute_group` (`attribute_set_id`, `attribute_group_name`, `sort_order`, `attribute_group_code`) VALUES (?, ?, ?, ?)
我在 phpMyAdmin 的搜索功能中搜索了 9-Gift Options,但我得到了 0 个结果。
我该如何解决这个问题?
我不得不在 phpmyadmin 中打开 table "eav_attribute_group"。然后我选择了 "Structure" 并查看了 "Indizes":
如您所见,EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME 设置为唯一,并使用 attribute_set_id 列构建 - attribute_group_name.
所以我搜索了重复键并将其删除:
SELECT * FROM `eav_attribute_group` WHERE `attribute_set_id` = 9 AND `attribute_group_name` = "Gift Options"