Magento Tutorials

How to Fix Unique Constraint Violation Found in Magento 2

Hello Magento Friends,

Welcome to Magento 2 Tutorials by MageComp. Today’s subject matter is How to Fix Unique Constraint Violation Found in Magento 2.

Magento 2 store merchants generally come across errors like “Unique constraint violation found” in the backend. Look at the below image.

The Unique Constraint Violation Found error usually occurs while adding categories, products, items, or creating new orders. The reason for this error can be the creation of duplicate values in the database table.

Let find out the solution for, How to Fix Unique Constraint Violation Found in Magento 2.

Steps to Fix Unique Constraint Violation Found in Magento 2:

The issue is related to the sequences table. So check the table of sequence_order_0 and sequence_order_1. 

sequence_value column should be auto_increment and set primary key.

Conclusion:

Hence, this way you can Fix Unique Constraint Violation Found in Magento 2. In case of any issue, reach out to me via the comment section. Share the article and help your friends to fix the problem.

Happy Reading!

Click to rate this post!
[Total: 12 Average: 4.7]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

  • Hi,
    I tried what you suggested but continue to get the same error still.

    Unique constraint violation found

    Running Magento 2.3.5 version and the table sequence_order_1 did have the problem so on making it auto increment and primary key thought it would solve the problem. Also applied Analyze table operation that fixed the cardinality value to the correct count but still the same error.

    So admin login not working and giving same error. Any help would be appreciated.

    Thanks.

Recent Posts

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

19 mins ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

18 hours ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

3 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…

3 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

4 days ago

Magento 2: How to Provide Access to your Custom Folder in the Media Gallery

Hello Magento Friends, In the current Magento 2 tutorial, I will describe the steps to…

5 days ago