step 7 duplicate entry issue in delta migration

Hello Team, 

I am facing issue of 
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1919403’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `quote` (`store_id`, `is_active`, `is_virtual`, `is_multi_shipping`, `items_count`, `items_qty`, `orig_order_id`, `store_to_base_rate`,  …
I want to know that if i am running migration with --mode=update then why this kind of error appear ?  and what is the correct solution to remove all duplicate entries ?

if i delete dupicate record manually and start migration again then its start from initial so its take more time. 
 
Thanks

6 answers

Profile photo of Mall Staff 184060.00 $tone May 16, 2020
Public

Hi there,

 1062 Duplicate entry ‘1919403’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `quote` (`store_id`, `is_active`, `is_virtual`, `is_multi_shipping`, `items_count`, `items_qty`, `orig_order_id`, `store_to_base_rate`,  …
I want to know that if i am running migration with --mode=update then why this kind of error appear ?  and what is the correct solution to remove all duplicate entries ?

That was because you checked the ‘KEEP ORIGINAL IDs’ setting in step #7 while your M2 database had some newly added sales data after the first migration.

To solve that issue, you have to delete all new sales data added in your M2 (which weren’t migrated by our migration tool) by running the following SQL queriess in your M2 database:

Delete From salesrule Where rule_id NOT IN (Select m2_id From ub_migrate_map_step_7 where entity_name = 'salesrule');
Delete From quote Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_7_quote where entity_name = 'sales_flat_quote' OR entity_name = 'sales_flat_quote_active');
Delete From quote_item Where item_id NOT IN (Select m2_id From ub_migrate_map_step_7_quote_item where entity_name = 'sales_flat_quote_item');
Delete From quote_address Where address_id NOT IN (Select m2_id From ub_migrate_map_step_7_quote_address where entity_name = 'sales_flat_quote_address');
Delete From sales_order Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_7_order where entity_name = 'sales_flat_order');
Delete From sales_order_item Where item_id NOT IN (Select m2_id From ub_migrate_map_step_7_order_item where entity_name = 'sales_flat_order_item');
Delete From sales_order_address Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_7_order_address where entity_name = 'sales_flat_order_address');

+ Once done, you can continue with the data migration in step #7 as normal.
 
PS. Since our team is off during the weekend, our apology for a certain delay when replying to you. We will follow up with you through out the weekend though. 

Regards,
Mall.

#2
Profile photo of rufflebutts 1660.00 $tone June 7, 2020
Public

Hello Team, 
Facing duplicate entry issues in step 7 

Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘141618’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `sales_order_tax` (`tax_id`, `order_id`, `code`, `title`, `percent`, `amount`, `priority`, `position`, `base_amount`, `process`, `base_real_amount`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10)

I need query to delete all duplicate entries not for single entry.

Please check and let us know

#3
Profile photo of Mall Staff 184060.00 $tone June 7, 2020
Public

Hi there,

1062 Duplicate entry ‘141618’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `sales_order_tax` (`tax_id`, `order_id`, `code`, `title`, `percent`,

Let’s run following SQL in your M2 database to delete the duplicated data record:

Delete From sales_order_tax Where tax_id = 141618;

And then, you continue with delta migration in step #7.
Regards,
Mall.

#4
Profile photo of rufflebutts 1660.00 $tone June 7, 2020
Public

Hello Team, 

This query is for single record but i need for all duplicate records as its takes lots of time to reach issue state and its not practical to do it again and again. 

Thanks

#5
Profile photo of Mall Staff 184060.00 $tone June 7, 2020
Public

Hi there,

This query is for single record but i need for all duplicate records

Let’s run followings SQL in your M1 database:

SELECT MIN(created_at) FROM `sales_flat_order`;

and let’s me know result of that. I will check further and get back you then.
Regards,
Mall.

#6

Please login or Register to Submit Answer

Written By

Comments