cancel
Showing results for 
Search instead for 
Did you mean: 

Unique constraint violation found after upgrading to Magento 2.3.3

SOLVED

Unique constraint violation found after upgrading to Magento 2.3.3

Hello, 

 

I just recently upgrade from Magento 2.3 to Magento 2.3.3 and whenever I am running "

php bin/magento setup:upgrade" SSH command it just stick on Unique constraint violation found. Any idea how do I fix this ?

 

Error after running the "php bin/magento setup:db-data:upgrade" SSH command:

 

In AbstractDb.php line 427:
                                     
  Unique constraint violation found  
                                     

In Mysql.php line 593:
                                                                           
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '  
  order-0' for key 'SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID', query was:  
   INSERT INTO `mg_sales_sequence_meta` (`entity_type`, `store_id`, `sequ  
  ence_table`) VALUES (?, ?, ?)                                            
                                                                           

In Mysql.php line 110:
                                                                           
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '  
  order-0' for key 'SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID', query was:  
   INSERT INTO `mg_sales_sequence_meta` (`entity_type`, `store_id`, `sequ  
  ence_table`) VALUES (?, ?, ?)                                            
                                                                           

In Mysql.php line 91:
                                                                           
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '  
  order-0' for key 'SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID'              
                                                                           

setup:db-data:upgrade [--magento-init-params MAGENTO-INIT-PARAMS]

Screenshot 2019-10-15 at 18.34.56.pngScreenshot 2019-10-15 at 19.14.05.png

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Unique constraint violation found after upgrading to Magento 2.3.3

I had something very similar happen to me when going from 2.2.6 to 2.3.0. I had to go into phpMyAdmin and run a query to find duplicates and manually delete entries. For me though it had to do with the attribute tables.

 

I've also had issues where the store id was missing for some reason and had to populate it into the tables.

 

Oh the headache many of us could be saved from if upgrades abstracted database integrity and file permissions for us.

View solution in original post

5 REPLIES 5

Re: Unique constraint violation found after upgrading to Magento 2.3.3

I had something very similar happen to me when going from 2.2.6 to 2.3.0. I had to go into phpMyAdmin and run a query to find duplicates and manually delete entries. For me though it had to do with the attribute tables.

 

I've also had issues where the store id was missing for some reason and had to populate it into the tables.

 

Oh the headache many of us could be saved from if upgrades abstracted database integrity and file permissions for us.

Re: Unique constraint violation found after upgrading to Magento 2.3.3

Hello @AndyAJ

I am having same issue while migrate from magento 1.X to magento 2.3.3

Could you please let me know in detail what exact need to be done ?

Thank you

Re: Unique constraint violation found after upgrading to Magento 2.3.3

Same issue on my installation, how we can run queries to find the problem on the database?

 

Can you help us provide a code to run and detail instructions to find the duplicates?

or at least a technique to locate them?

Re: Unique constraint violation found after upgrading to Magento 2.3.3

I have got same issue after migration. I follow bellow step to solve order , shipment and invoice issue. Might be its not proper solutions but its work for me.

 

I have update all order,invoice,shipment invoice tables.

 

sequence_shipment_0,sequence_shipment_1,sequence_invoice_0,sequence_invoice_1 tables.

alter sequence_value column with auto increment primary key . and insert dummy 1 to 5 values. After that i have clean cache and every order , shipment and invoice generated ..

sequence_shipment_0

Re: Unique constraint violation found after upgrading to Magento 2.3.3

How would one do that? 

 

I'm in phpMyAdmin in sequence_shipment_ but I am not sure how to do that? Would you give step-by-step on this? 

 

Thank you.