Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento -- "SQLSTATE[23000]: Integrity constraint violation.." on customer update

After migrating servers, I'm getting an error every time I try to update customer information. I'm using a customer activation plugin, but after disabling it, I still get the same error.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '7-127' for key 2

What is wrong?

Even after uninstalling the plugin, I get this error while trying to save customer information. So this leads me to believe its a bigger problem with Magento and/or the server I'm switched to.

I checked the Magento's log and I'm getting this Notice multiple times:

ERR (3): User Notice: Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core  in ../httpdocs/store/lib/Zend/Locale/Format.php on line 769

Is this relevant?

like image 846
Luke Burns Avatar asked May 23 '11 21:05

Luke Burns


People also ask

What causes integrity constraint 23000 violation?

Fixed: SQLSTATE[23000]: Integrity constraint violation: 1052 This issue occurs when more than one table are having the same column name and in a join query, the column name is being used without the alias of the table name.

How do you correct an integrity constraint violation?

In order to remedy this error, you will need to insert the value that you attempted to place in the child table into the parent table first. Once inserted as a parent row, you can go back and insert the value into the child table.

What is the meaning of integrity constraint violation?

Integrity constraint violations occur when an insert, update, or delete statement violates a primary key, foreign key, check, or unique constraint or a unique index.


1 Answers

The issue is because when you migrated your database, mysql helpfully restarts the id columns that are auto-increment and Magento has some hardcoded values that assume that IDs start from zero. You need to disable foreign_key_checks when you import the data.

like image 164
Jonathan Day Avatar answered Oct 13 '22 18:10

Jonathan Day