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

3

5

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?

Suture answered 23/5, 2011 at 21:54 Comment(3)
Some code in your Magento system is causing SQL to run which tries to insert data into a database column that's been declared with a unique key. The possible causes for this are legion and if you want an answer on this forum you'll need to put in some debugging time.Bitthia
I've updated with all I found in Magento's log.Suture
"What happens when you trace the SQL that's being run", he asked passive-aggressively.Bitthia
T
9

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.

Tambourine answered 24/5, 2011 at 8:19 Comment(1)
This is a dead link. Would've been nice to have a copy-paste here for posterity....Sousa
S
1

Your edit is attempting to re-CREATE the user, instead of UPDATE-ing the existing user. It's a bug with the plugin. You may want to report it to the author or wait for an update to come out.

Survival answered 23/5, 2011 at 22:1 Comment(0)
P
1

If you are trying to import SQL file , make sure that you “Disable foreign key checks” . For that just add SET FOREIGN_KEY_CHECKS = 0; at the start of SQL file. Also add SET FOREIGN_KEY_CHECKS = 1; at the end of file.

Preiser answered 12/8, 2012 at 18:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.