I am trying to remove a catalog_product custom attribute the Magento way by using Mage_Eav_Model_Entity_Setup::removeAttribute() but it results in bad data integrity: the attribute gets deleted from eav_attribute table but not from catalog_eav_attribute.

When doing

show create table catalog_eav_attribute

I see the the attribute_id FK to eav_attribute defined correctly with on delete cascade in place

Is this a known bug of Magento or rather a mysql bug?

Magento version is, mysql version is 5.5.46 running on ubuntu 14.04.2

Edit: I tried to reproduce the error by mocking a custom relationship between two custom tables using a foreign key constraint with on delete cascade enabled and it worked: when I deleted a row in the parent table, all related rows in child table were deleted accordingly. Why won't the same work for the eav_attribute and catalog_eav_attribute tables?

Edit2: the same happens with other tables referencing the eav_attribute table: eav_attribute_option, eav_attribute_option_value, customer_eav_attribute, etc, leaving Magento with lots of orphaned child rows in aforementioned tables.

  • You do understand that Magento is built on the EAV system? If you remove part of it or all of it Magento won't work. May 19, 2016 at 9:06
  • The attribute in question is a custom attribute I have added previously. What do you mean by "Magento won't work"? :)
    – adjco
    May 19, 2016 at 11:15
  • my bad, I misunderstood your question, I thought you wanted to delete attributes from the EAV model. Have you tried deleting your attribute from the attribute panel in the backend? If so, what does it do? May 19, 2016 at 11:54
  • There is magerun extension called Eav cleaner that can help.
    – snh_nl
    Oct 31, 2020 at 14:49

1 Answer 1


If you are removing an attribute using an upgrade script and you have this line at the start of the file


remove it.
It just disables the foreign key checks.


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.