after upgarde getting this error Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (au.#sql-40d4_c, CONSTRAINT SALES_ORDER_CUSTOMER_ID_CUSTOMER_ENTITY_

2 Answers 2


It just simply means that the value for column COLUMN_NAME on table TABLE_NAME1 you are inserting doesn't exist on table TABLE_NAME2

The value "abcdefgh" you are inserting for column COLUMN_NAME does not exist on table youa re trying to inssert.

check your database table

  • but i am upgrading my magento <constraint xsi:type="foreign" referenceId="SALES_ORDER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="sales_order" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="SET NULL"/>
    – imtiazau
    Commented Oct 30, 2019 at 11:31
delete from sales_order where customer_id not in (select `entity_id` from `customer_entity`)

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.