Order data migration status fail – duplicate entry

Hi there,

Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘237102’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `sales_order_item` (`order_id`, `weight`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `free_shipping`, `item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `is_virtual`, `sku`, `name`, `is_qty_decimal`, `original_price`, `base_original_price`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10, :yp11, :yp12, :yp13, :yp14, :yp15, :yp16, :yp17, :yp18, :yp19, :yp20, :yp21, :yp22, :yp23, :yp24, :yp25, :yp26, :yp27, :yp28, :yp29, :yp30, :yp31, :yp32, :yp33, :yp34, :yp35, :yp36, :yp37, :yp38, :yp39, :yp40, :yp41, :yp42, :yp43, :yp44, :yp45, :yp46, :yp47, :yp48, :yp49, :yp50, :yp51, :yp52, :yp53, :yp54, :yp55, :yp56)

Getting this error for Delta migration for orders DATA.

7 answers

Profile photo of Mall Staff 184060.00 $tone August 1, 2019
Public

Hi there,

Getting this error for Delta migration for orders DATA.

That was because you checked the ‘KEEP ORIGINAL IDs’ option in step #7 of our migration tool. And after the first migration, your M2 site had some new sales orders created.
 
To continue with delta migration in step #7, you have to delete all the new sales orders added in M2 after the first migration.
 
Regards.
Mall.

#1
Profile photo of Mall Staff 184060.00 $tone August 1, 2019
Public

Hi there,

we do not have any new orders in M2 site.

So, the duplicated issue you mentioned is strange. Please follow up my answer in this post and provide me information of your instance as mentioned in my reply #7. 

I will help to check further and get back to you then.
 
Regards,
Mall.

#3
Profile photo of Mall Staff 184060.00 $tone August 1, 2019
Public

Hi there,

what does the reset option do?

The reset function will delete all data records migrated by our migration tool in your M2 database (Please note you can reset just one single Step, or all Steps. You can refer to our Readme -- Section 5 -- How to use to learn about the CLI command for the Reset feature).

will it erase all the data in step 7 if I want to reset and data migration again?

To save your time, before you did that, please try with steps below first to solve the issue you mentioned above:

1062 Duplicate entry ‘237102’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `sales_order_item` (`order_id`, `weight`, 

+ Step 1: Run the following SQL in your M2 database to delete the record in thetable ‘sales_order_item’ which caused the duplicated issue:

Delete From sales_order_item Where item_id = 237102;

+ Step 2: Continue data migration in the step #7 by running the command:
php -f bin/ubdatamigration run --step=7;

Regards,
Mall.

#5
Profile photo of vkulkarni 610.00 $tone August 21, 2019
Public

Hi there,
getting a duplicate entry in sales_order

Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘117144’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `sales_order` (`total_item_count`, `paypal_ipn_customer_notified`, `mailchimp_abandonedcart_flag`, `mailchimp_campaign_id`, `mailchimp_flag`, `entity_id`, `state`, `status`, `coupon_code`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`, `base_discount_invoiced`, `base_grand_total`, `base_shipping_amount`, `base_shipping_invoiced`, `base_shipping_tax_amount`, `base_subtotal`, `base_subtotal_invoiced`, `base_tax_amount`, `base_tax_invoiced`, `base_to_global_rate`, `base_to_order_rate`, `base_total_invoiced`, `base_total_invoiced_cost`, `base_total_paid`, `discount_amount`, `discount_invoiced`, `grand_total`, `shipping_amount`, `shipping_invoiced`, `shipping_tax_amount`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `subtotal_invoiced`, `tax_amount`, `tax_invoiced`, `total_invoiced`, `total_paid`, `total_qty_ordered`, `customer_is_guest`, `customer_note_notify`, `billing_address_id`, `customer_group_id`, `email_sent`, `quote_id`, `shipping_address_id`, `base_shipping_discount_amount`, `base_subtotal_incl_tax`, `base_total_due`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `increment_id`, `applied_rule_ids`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `discount_description`, `global_currency_code`, `order_currency_code`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `created_at`, `updated_at`, `shipping_incl_tax`, `base_shipping_incl_tax`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10, :yp11, :yp12, :yp13, :yp14, :yp15, :yp16, :yp17, :yp18, :yp19, :yp20, :yp21, :yp22, :yp23, :yp24, :yp25, :yp26, :yp27, :yp28, :yp29, :yp30, :yp31, :yp32, :yp33, :yp34, :yp35, :yp36, :yp37, :yp38, :yp39, :yp40, :yp41, :yp42, :yp43, :yp44, :yp45, :yp46, :yp47, :yp48, :yp49, :yp50, :yp51, :yp52, :yp53, :yp54, :yp55, :yp56, :yp57, :yp58, :yp59, :yp60, :yp61, :yp62, :yp63, :yp64, :yp65, :yp66, :yp67, :yp68, :yp69, :yp70, :yp71, :yp72, :yp73, :yp74)

how to delete this?
and 
is this due to

orders created from Magento 2 after migration?

Thank you

#6
Profile photo of Mall Staff 184060.00 $tone August 22, 2019
Public

Hi there,

is this due to

 orders created from Magento 2 after migration?

Yes that is right.

Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘117144’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `sales_order` (`total_item_count`, `paypal_ipn_customer_notified`, 
… how to delete this?

You can run the following SQL in your M2 database:

Delete From sales_order Where entity_id = 117144;

+ Once done, continue with the data migration in the step #7:
php -f bin/ubdatamigration run --step=7

Regards,
Mall.

 

 

#7

Please login or Register to Submit Answer

Written By

Comments