13

Anyone having this issue?

data migration > EAV Step

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-Migration_Default' for key 'EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_ATTRIBUTE_SET_NAME'

1
  • Have you found any solution for this? Commented Sep 15, 2017 at 7:34

8 Answers 8

4

This error occurs when the migration tool fails to transfer data (e.g. due to integrity violations) without rolling back, and is ran again. It attempts to create "Migration_Default" attribute set and fails, because it already is present in the database.

What you have to do is to:

1) Restore your Magento 2.0 database from a copy that you (hopefully) made before running the migration tool.

2) Run the migration tool again and check for the first error that it fails on. In my case it was:

[PDOException]                                                                                                              
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'home-1' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID'

3) Fix the problem (I had to manually remove a row in the DB).

Repeat the steps until you've cleared all errors and see the sweet sounding message:

Migration completed
5
  • I am facing same issue, Where i can change this value? Commented Aug 11, 2016 at 12:16
  • 1
    Which value? How to remove a DB row that's causing an integrity constraint violation? Look at the index name. In my case it was "URL_REWRITE_REQUEST_PATH_STORE_ID". The first part of it is the name of the table with the offending record. In my case it was url_rewrite (or more precisely my-prefix_url_rewrite). REQUEST_PATH and STORE_ID are two columns that when put together have to be unique. In my case the migration tool was trying to insert two records with "home" under request_path and 1 under store_id. I had to remove the first one.
    – Mateusz
    Commented Aug 12, 2016 at 15:31
  • @Mateusz, if we use command, -r it will not reset the db and start from beginning? every time restoring db is too time taking processs Commented Apr 16, 2019 at 10:10
  • @jafarpinjar (or anyone else looking at this) Yes that is correct. You need to restore the database each time. From Magento 2's documentation: "To force the Data Migration Tool to run from the beginning, use the --reset argument. In that case, we recommend you restore your Magento 2 database dump to prevent duplicating previously migrated data."
    – WackGet
    Commented Mar 6, 2020 at 3:31
  • @Mateusz, I have this error, "Integrity constraint violation: 1062 Duplicate entry '0' for key 'WISHLIST_CUSTOMER_ID'" Commented Mar 9, 2020 at 15:25
3

I found this solution that solved this issue for me https://github.com/magento/data-migration-tool/issues/235#issuecomment-321923437

Solution is to rename all values containing the name "Default" in "attribute_value_name" field of eav_attribute_set table to "Default_x" in the Magento 1 database and run the migration from scratch.

In my case, there were 9 records with name "Default". So I renamed them to Default_1 to Default_9 and it worked perfectly!

2
  • Thanks, this worked for me too. Next I got a related duplicate key error on EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_CODE, and resolved that by a similar approach: UPDATE eav_attribute_group SET attribute_group_name = CONCAT(attribute_group_name, "_", attribute_set_id) WHERE attribute_group_name = "General";
    – WackGet
    Commented Mar 6, 2020 at 3:35
  • @Alfredo Lanzetta, I have successfully migrated to M2, but seem to have an issue with custom layout option. I would like your insights about the same. Could you please have a look at my question? Commented Mar 24, 2020 at 4:06
2

In my case: It happened to me and I had to import a backup of my magento 2 database before reloading migration.

At your case: Maybe you had to reload data migration a second time.

2
  • hi @Kevin, reset command will not reset the settings? it will not start from beginning? every time need to reset the db? Commented Apr 16, 2019 at 10:08
  • @jafarpinjar (or anyone else looking at this) Yes that is correct. You need to restore the database each time. From Magento 2's documentation: "To force the Data Migration Tool to run from the beginning, use the --reset argument. In that case, we recommend you restore your Magento 2 database dump to prevent duplicating previously migrated data."
    – WackGet
    Commented Mar 6, 2020 at 3:31
1

To fix this issue,

  1. First you need to check for already migrated attribute sets.
  2. Then delete those attribute sets except the default one.

You can do that through your SQL querying application or interface.

DELETE FROM eav_attribute_set WHERE attribute_set_name != 'Default';
1

Double check with your migrating Database Magento 2. Sometimes We didn't change the database name in the data migrating tool.

Reinstall fresh Magento instance and correctly add database name in data migrating tool

0

Data-Migration-Tool does not receive data from the source in utf8.
Here is a simple solution to this problem:

Edit: vendor/magento/data-migration-tool/src/Migration/ResourceModel/Adapter/Mysql.php

public function __construct(
    \Magento\Framework\DB\Adapter\Pdo\MysqlFactory $adapterFactory,
    \Magento\Framework\DB\Ddl\TriggerFactory $triggerFactory,
    array $config
) {
    $config['initStatements'] = 'SET NAMES utf8'; // +
    $configData['config'] = $config;
    $this->resourceAdapter = $adapterFactory->create($configData);
    $this->setForeignKeyChecks(0);
    $this->triggerFactory = $triggerFactory;
}

GitHub

1
  • Can you explain why this would make a difference on duplicating a primary key? Commented Nov 20, 2018 at 0:31
0

In my experience, there is sample data installed. So, i have done the following steps.

  1. I dropped the database
  2. Then reinstall magento 2 again without sample data.

Then, I can migrate.

0

Fixed my issue with following sql:

Integrity constraint violation: 1062 Duplicate entry ‘4-Images’ for key – Magento 2

delete from eav_attribute_group WHERE attribute_group_name = 'Images';

So try something

delete from eav_attribute_group WHERE attribute_group_name = 'Home';

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.