Skip to content

Integrity constraint violation: 1452 Cannot add or update a child row #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Shane1812 opened this issue Dec 18, 2018 · 10 comments
Closed

Comments

@Shane1812
Copy link

migrate data from magento 1.9.2.4 to magento2.26

Steps to reproduce

  1. I test my migration tool from a copy database on local successfully.then try to migrate the data from a live database to another live database,and it failure.
  2. I can not find the table 'catalog_product_entity_varchar' on magento 1 so I am not sure what's the
    process of migration.Please help

[2018-12-18 12:17:42][INFO][mode: data][stage: data migration][step: Map Step]: started
12% [===>------------------------] Remaining Time: 1 hr

[PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fai
ls (dbname.catalog_product_entity_varchar, CONSTRAINT CAT_PRD_ENTT_VCHR_ATTR_ID_EAV_ATTR_A TTR_ID FOREIGN KEY (attribute_id) REFERENCES eav_attribute (attribute_id))

@victor-v-rad
Copy link
Collaborator

Hi @Shane1812
It seems like orphaned record caused error. The tool checks for orphaned records at the beginning of migration and throw error like #455 If that was the case and you skipped this error by --auto option then read how to properly resolve it in this guide. Still, during migration of data in Map Step you should not have got this error because the tool send SET FOREIGN_KEY_CHECKS=0 before migration. This prevents MySQL to throw the error you described. So maybe your live MySQL instance ignores this SET FOREIGN_KEY_CHECKS=0

@Shane1812
Copy link
Author

Hi @Shane1812
It seems like orphaned record caused error. The tool checks for orphaned records at the beginning of migration and throw error like #455 If that was the case and you skipped this error by --auto option then read how to properly resolve it in this guide. Still, during migration of data in Map Step you should not have got this error because the tool send SET FOREIGN_KEY_CHECKS=0 before migration. This prevents MySQL to throw the error you described. So maybe your live MySQL instance ignores this SET FOREIGN_KEY_CHECKS=0

Hi,thank you for your help,I think it is because the database ignores the SET FOREIGN_KEY_CHECKS=0,the server database is MariaDB,I think the tool set foreign key checks disable dont work on MariaDB,and I am not sure how to make it works...

@Shane1812
Copy link
Author

@victor-v-rad hi,I think it should not happen because I can see the data exsit in eav_attribute table.it should can find all the attribute _id at the table.I am so confused.

@victor-v-rad
Copy link
Collaborator

Did you see #455 error at the beginning of migration?

@Shane1812
Copy link
Author

@victor-v-rad yes,it is not that error,I run the command without -a,and it shows no error.now I try to migrate the data from live database to my computer,and it's still stucked in this step even SET GLOBAL FOREIGN_KEY_CHECKS=0;I got stucked at 'catalog_product_entity_media_gallery_value' in this error too and after I clear some data from my M1 database it migrated smoothly,but in this table I dont know what need to clear because I can find all attribute_id(catalog_product_entity_varchar) in eav_attribute table.

@victor-v-rad
Copy link
Collaborator

victor-v-rad commented Dec 20, 2018

after I clear some data from my M1 database it migrated smoothly

So was it fixed?

@Shane1812
Copy link
Author

@victor-v-rad no at this table,I met this error before but not this table but in 'catalog_product_entity_media_gallery_value',that after I clear the data it now can find the data from M2 database means the table migrate successfully.but catalog_product_entity_varchar this table still get stucked.

@victor-v-rad
Copy link
Collaborator

Maybe catalog_product_entity_varchar has records with empty attribute_id

@Shane1812
Copy link
Author

@victor-v-rad I can find all attribute_id(catalog_product_entity_varchar) in eav_attribute table.that's why I am so confused.

@Shane1812
Copy link
Author

@victor-v-rad I copy the live server database to local server and migrate smooth...then delta it with server database,get this warning:
[2018-12-20 10:37:19][WARNING]: Mismatch of entities in the document: adminnotification_inbox Source: 8877 Destination: 8876
[2018-12-20 10:37:19][WARNING]: Mismatch of entities in the document: catalog_product_entity_int Source: 148744 Destination: 130480
[2018-12-20 10:37:19][WARNING]: Mismatch of entities in the document: catalog_product_entity_varchar Source: 272901 Destination: 250589
[2018-12-20 10:37:19][WARNING]: Volume Check failed
I think that's problem,there are rows missed after migration.Is these data take effect to my M2 website?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants