0

I've been having issues while using the data migration tool to migrate data from Magento 1.9.3 to Magento 2.3:

I already setup the config.xml to migrate only Customers and Sales. I then run the following commands:

php bin/magento migrate:settings --reset vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml

php bin/magento migrate:data --auto vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml

and then get the following error:

In Mysql.php line 182: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000003-1' for key 'SALES_CREDITMEMO_INCREMENT_ID_STORE_ID'

The Magento 2 database sales_creditmemo_* tables are all empty, so I'm clueless. Any help is greatly appreciated.

2 Answers 2

0

please note for migration you must make sure there are no any order placed in magento2. In short u need to use fresh database.if you have order,invoice,shipment,creditmemo then please delete all order from magento2 database.

here you can find free extension for delete order : https://bsscommerce.com/magento-2-delete-order-extension.html

please accept as a solution if you found it helpfull :)

2
  • Thank you, but I already used mageplaza.com/magento-2-delete-orders to delete all the test orders we did. There are no more orders, credit memos, invoices, shipments, yet the error still comes up. Commented May 2, 2021 at 1:57
  • Please once search "100000003-1" in whole database. Commented May 3, 2021 at 3:32
0

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

NOTE: 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

2
  • A database backup has not been made - is there a migration log that would point out the tables / changes made to the database (so that I can revert back to that)? Commented May 4, 2021 at 15:35
  • Unfortunately, there is no tool for you to revert to your old database. However, you can create a backup at the present time then follow the next steps in my answer above. Commented May 5, 2021 at 3:15

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.