cancel
Showing results for 
Search instead for 
Did you mean: 

Upgrade from 2.2.7 to 2.4.1 SQLSTATE[23000]: Integrity constraint violation: 1452

Upgrade from 2.2.7 to 2.4.1 SQLSTATE[23000]: Integrity constraint violation: 1452

Hi  I am trying to upgrade from 2.2.4 to 2.4.1 and I get this error 

 

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`building_staging`.`#sql-dae_1904c`, CONSTRAINT `CAT_PRD_ENTT_DEC_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE), query was: ALTER TABLE `catalog_product_entity_decimal` MODIFY COLUMN `value` decimal(20, 6) NULL COMMENT "Value", ADD CONSTRAINT `CAT_PRD_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID` FOREIGN KEY (`attribute_id`) REFERENCES `eav_attribute` (`attribute_id`) ON DELETE CASCADE, ADD CONSTRAINT `CAT_PRD_ENTT_DEC_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE, ADD CONSTRAINT `CATALOG_PRODUCT_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `store` (`store_id`) ON DELETE CASCADE

 

ive looked all over online and found little in the way of answers any help please?

 

thanks 

4 REPLIES 4

Re: Upgrade from 2.2.7 to 2.4.1 SQLSTATE[23000]: Integrity constraint violation: 1452

Hello @m5solutions ,

 

This error says, that the database is unable to write something to a table

its means that there is a foreign key that is not satisfied (ie you need it to exist but it doesn't)

catalog_product_entity must have an entry for entity_id which is  referenced.

 

Thank You

 

Re: Upgrade from 2.2.7 to 2.4.1 SQLSTATE[23000]: Integrity constraint violation: 1452

so how to fix?

Re: Upgrade from 2.2.7 to 2.4.1 SQLSTATE[23000]: Integrity constraint violation: 1452

Check in the latest extension database file (db_schema.xml file).

If they use product_id in any table then mageworx table which uses the product_id column type must be the same as the catalog_product_entity table entity_id field.

if the column type doesn't match for both then try to update the mageworx table column type and run setup:upgrade.

If issue solved, Click Kudos & Accept as Solution.
LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool

Re: Upgrade from 2.2.7 to 2.4.1 SQLSTATE[23000]: Integrity constraint violation: 1452

Did you manage it i was having issue please share the suggestion thanks in advance.

my gift card site