Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'

Magento Asked on December 20, 2020

I’m trying to migrate from Magento 1 to 2 and when I get to this part:

[2017-10-06 14:04:36][INFO][mode: data][stage: data migration][step: Map Step]: started
33% [=========>——————] Remaining Time: 3 mins

I then get this error

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘0’ for key ‘PRIMARY’

Any ideas?

4 Answers


worked for me inside the map.xml (or map.xml.dist) source -> field_rules node

Answered by DKNZDESIGN on December 20, 2020

The problem should go away if you change bulk_size to something other than 0 in your config.xml. It doesn't seem to auto-detect correctly on the customer_group table. Setting mine to 100 solved the problem for me.

To find out what table is the problem, try adding some debugging info to your src/Migration/Step/Map/Data.php file. Something like $this->logger->info("DEBUG: " . $sourceDocName ); around line 136. This should output the table the migration tool is currently working on in the console.

Answered by Sean Michaud on December 20, 2020

I had the same problem.. to get past it at least temporarily, I added this to the map.xml file under source and under document_rules


Answered by Anthony B on December 20, 2020

I am getting the same error. When doing the migration with verbose mode on, I can see that the issue is with the "customer_group" table. Primary key 0 is the "NOT LOGGED IN" customer group.

That is how far I am into for now. I will let you know if I find anything else.

Answered by Wesley J on December 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP