3

I am using this data-migration-tool, When i migrate from magento 1.9.3.2 to magento 2.3,getting below error,

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'SALES_ORDER_INCREMENT_ID_STORE_ID'

i tried many times upload fresh DB,still getting this issue

  • Do you have orders with no increment_id in your database? That shouldn't be possible since there is an unique index on that column, but the key in your error looks like that – HelgeB Feb 18 at 15:53
  • Do you have orders with no increment_id in your database? >>>which table i have to check ? – sumeet bajaj Feb 19 at 7:05
  • sales_flat_order in your Magento 1 database. – HelgeB Feb 19 at 7:11
  • yes sales_flat_order,entity_id is auto increment and all entity_id are unique – sumeet bajaj Feb 19 at 7:16
  • not entity_id but increment_id – HelgeB Feb 19 at 7:43
1

The error occurs if there are orders in the Magento 1 database with no increment_id set. You can check if you have such orders by running the following SQL statement in your Magento 1 database:

select count(*) from sales_flat_order where increment_id = '' OR increment_id is NULL;

If the returned value is greater than 0, you should update the tables sales_flat_order and sales_flat_order_grid in such a way to ensure that all your orders have increment_ids and those are unique.

If you find incrment_ids in the sales_flat_order_grid table for all orders, just take the values from there with the following statemen:

update sales_flat_order o 
join sales_flat_order_grid g 
    on o.entity_id = g.entity_id  
set o.increment_id = g.increment_id 
where o.increment_id = '' OR o.increment_id is NULL;

If you don't find orders without any increment_id it might be the best option to create arbitrary increment_ids. For example you can use a SQL update statement which builds an increment_id based on the entity_id and a prefix of your choice (just replace the prefix in the sample statements with something which doesn't conflict with existing increment_ids):

update sales_flat_order set increment_id = concat ('990000', entity_id) where increment_id is null;
update sales_flat_order_grid set increment_id = concat ('990000', entity_id) where increment_id is null;
  • thanks @HelgeB, you are awesome,fantastic,thanks for your valuable time – sumeet bajaj Feb 19 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.