After updating one of my extensions (which was required because I updated to Magento 2.4.4), I am getting this error when I run the upgrade command:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '646-1' for key 'AMASTY_ORDER_ATTRIBUTE_ENTITY_ENTITY_ID_PARENT_ENTITY_TYPE', query was: ALTER TABLE `amasty_order_attribute_entity` ADD CONSTRAINT `AMASTY_ORDER_ATTRIBUTE_ENTITY_ENTITY_ID_PARENT_ENTITY_TYPE` UNIQUE KEY (`entity_id`,`parent_entity_type`)

Any idea how to fix that?


  • delete that entry from that table and run setup upgrade command again Aug 18, 2022 at 10:01
  • How would the delete query look like? I dont know which value the 646-1 refers to (which column)? Aug 18, 2022 at 10:05
  • "amasty_order_attribute_entity" is table, and this is colum "AMASTY_ORDER_ATTRIBUTE_ENTITY_ENTITY_ID_PARENT_ENTITY_TYPE" and Value is "646-1" Aug 18, 2022 at 10:08
  • There is no such column in that table ... it only has 4 column (see i.imgur.com/ozjiNa2.png) Aug 18, 2022 at 10:29
  • parent_entity_type Aug 18, 2022 at 11:14

1 Answer 1

  1. Go to your database.
  2. Find the amasty_order_attribute_entity table.
  3. In the table, select * from amasty_order_attribute_entity where 'AMASTY_ORDER_ATTRIBUTE_ENTITY_ENTITY_ID_PARENT_ENTITY_TYPE' = '646-1'
  4. Remove it

Run the upgrade command again

  • This returns no rows :-| Aug 18, 2022 at 22:12

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.