I have a site in D5 with several languages configured (English, French, Italian, Spanish). Upgrading from D5 to D6 gives me the following error:

user warning: Duplicate entry '1-0' for key 1 query: ALTER TABLE locales_target ADD PRIMARY KEY (language, lid, plural) in /home/gmpmprdg/public_html/support/includes/database.mysql-common.inc on line 374

I seem to have gotten around this by executing the command manually in phpmyadmin

Comments

JirkaRybka’s picture

I had this problem too (with only one language enabled [Czech]) - it's caused by duplicate records in {locales_target} table, which are (in my case at least) just empty translations for untranslated strings. Since these are discovered and stored into the database on-the-fly, it most probably happens (extremely rarely) that two concurrent page requests are able to both insert own copy of the same string [just a guess how the records got there, but my site certainly DID have quite a few].

Anyway, I executed this query from PhpMyAdmin, just prior to running update.php to bring my database from 5.x to 6.x:
DELETE FROM `locales_target` WHERE translation = ''(Don't forget to add your table prefix, if any.) There's no harm in that deletion, since core does this anyway (actually, the query is verbatim from locale_update_6002() ). Removing these entries earlier only just allows the index addition (in system_update_6043() ) to be successful, because locale updates didn't run yet, when it fires. IMO, the order of these two updates might be considered a minor bug, indeed, but not changing status now. (Should this go into update system queue, locale.module, system.module, or is it even a won't fix being about reordering update functions on a stable release? Or add a new update function re-doing some stuff if missing? I'm rather unsure.)

Adding the index post-upgrade manually (as suggested in initial post) should work too, as locale_update_6002() already executed the other query. It's really just the order that matters, but index-addition query is a tiny bit more difficult IMO. (I would say, even manual selection of updates (first locale, then the rest) might help, but that's waaay too risky to do without all sorts of investigations and tests.)

gbaudoin’s picture

Status: Active » Closed (won't fix)

Please retry on the latest 6.x version and re-open if necessary.