SQL 1062 Duplicate entry error in step 7

Hello
 
Thank you for wonderful software ! I run it but in the step 7 i got this error. How to fix it ?
php -f bin/ubdatamigration run --step=7
[Processing][run] in step #7: ……
Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘2306360’ 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`, `store_to_quote_rate`, `grand_total`, `base_grand_total`, `customer_group_id`, `customer_note_notify`, `customer_is_guest`, `trigger_recollect`, `is_persistent`, `entity_id`, `created_at`, `updated_at`, `base_currency_code`, `store_currency_code`, `quote_currency_code`, `customer_id`, `customer_tax_class_id`, `customer_email`, `customer_firstname`, `customer_lastname`, `remote_ip`, `applied_rule_ids`, `reserved_order_id`, `global_currency_code`, `base_to_global_rate`, `base_to_quote_rate`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `is_changed`) 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)

BR:Ari

4 answers

Profile photo of Mall Staff 184060.00 $tone November 12, 2021
Public

Hi there,

1062 Duplicate entry ‘2306360’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `quote` 

That issue occurred because you checked ‘KEEP ORIGINAL IDs’ setting in step #7 while you added new data in the sales data section in M2 after the first migration.

You can try these steps to fix it:

1. Run the following SQL queries in your M2 database to delete all sales data which were not migrated by our migration tool:

Delete From salesrule Where rule_id NOT IN (Select m2_id From ub_migrate_map_step_7 where entity_name = 'salesrule');
Delete From salesrule_coupon 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');
Delete From sales_invoice Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_7_invoice where entity_name = 'sales_flat_invoice');
Delete From sales_invoice_item Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_7_invoice_item where entity_name = 'sales_flat_invoice_item');

2. Then continue with data migration in step #7 by running this command:

php -f bin/ubdatamigration run --step=7;

Regards,
Mall.

#1
Profile photo of apelix 250.00 $tone November 12, 2021
Public

Hi
It’s not working, I receive this error:
failed : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘Delete From salesrule_coupon Where rule_id NOT IN (Select m2_id From ub_migra…’ at line 1
How to change it ? I did not import salesrules yet.
 
Ari
 
 

#2
Profile photo of apelix 250.00 $tone November 12, 2021
Public

I tested all lines, line by line and I got this error from all lines:
failed : Table ‘magento2.ub_migrate_map_step_7_invoice_item’ doesn’t exist
And I did not found this table from the database.

#3
Profile photo of Mall Staff 184060.00 $tone November 14, 2021
Public

Hi there,

failed : Table ‘magento2.ub_migrate_map_step_7_invoice_item’ doesn’t exist
And I did not found this table from the database.

That is strange. 
By your new information, please try again with steps as the following:
1. Run the following SQLs in your M2 database to delete all sales quotes in M2 which are not migrated by our migration tool:

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');

2. And then, you continue with data migration in step #7:

php -f bin/ubdatamigration run --step=7;

And tell me how it goes.
Regards,
Mall.

#4

Please login or Register to Submit Answer

Written By

Comments