How to fix “Unique constraint violation found” in Magento 2 Checkout Page After Migration

img How to fix Unique constraint violation found at Checkout page in Magento2 after migration

Magento 2 uses new approaches with new and enhanced design, and database that gives store owners to enhance their shopping experiences, increase security & functionality compared to Magento 1. Out of the box, Magento 2 comes with new user interface along with the capability of handling a large amount of data. To take advantage of these features and capabilities, Magento Store owners are migrating their existing store to feature pack Magento2 at a rate of knots. Migrating existing Magento store without losing data is one of the trickiest and the complex processes that need an attention and care to smoothly migrate your store. Recently, while upgrading a client’s web store, we faced an issue of “Unique constraint violation found” at product checkout in Magento 2 as shown below.

Constraint

After mining the reason behind this issue, we found that to fix this issue, we have to manually add some entries to the database. We need to add ‘meta_id’ manually in ‘sales_sequence_profile’ table which defines in ‘sales_sequence_meta’ of a database as described below.
First of all, we need to add ‘meta id’ to ‘sales_sequence_meta’ table.

add ‘meta id’ to ‘sales_sequence_meta’ table

After adding ‘meta id’ to ‘sales_sequence_meta’ table, you need to add those ‘meta id’ to ‘profile id’ into existing ‘sales_sequence_profile’ table and additionally, we have to add more entry in ‘prefix’ column.

add ‘meta id’ to ‘profile id’ into existing ‘sales_sequence_profile’ table

Once you are done, now you are unstoppable. Just clear the cache and your issue of “Unique Constraint Violation Found” is resolved.

Generally, we have noticed that the issue occurs while migrating a Magento store to 2.1.0 or later versions. Let me know with which Magento 2 version you are trying this code and also let me know in the comment section, if you are facing any issue while implementing this method.
Happy Fixing!

Previous Article

How to Create SimpleXMLElement Object in Magento 2

Next Article

How to Convert CURL XML Response into an Array in Magento 2

Write a Comment
  1. Murtaza Imran

    Hey Dhiren ,

    I have same problem and I am trying to do your solution but the problem is that I dont have any store with id 2 so would it work if there is no store with id 2.

    Regards

  2. I have faced an issue when I upgraded the Magento 2 version 2.3.2 to 2.3.7 then faced that issue. And ‘sales_sequence_meta’ & ‘sales_sequence_profile’ Table already added value as per you solution. But facing same error.

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨