I've got the following errors when upgrading from 1.x-alpha5 to 2.0-beta1.
Update #6013
* Failed: ALTER TABLE {l10n_community_translation} DROP INDEX is_active
* Failed: ALTER TABLE {l10n_community_translation} DROP INDEX is_suggestion
* Failed: ALTER TABLE {l10n_community_translation} DROP INDEX language
* ALTER TABLE {l10n_community_translation} DROP INDEX suggestion_active
* ALTER TABLE {l10n_community_translation} DROP INDEX sid_language_suggestion
* ALTER TABLE {l10n_community_translation} DROP INDEX sid
* ALTER TABLE {l10n_community_translation} ADD INDEX is_suggestion_is_active_language (is_suggestion, is_active, language)
* ALTER TABLE {l10n_community_translation} ADD INDEX sid_language_is_suggestion_is_active (sid, language, is_suggestion, is_active)
Checked the table and there is no index with this name... now checked hook_schema and found inconsistencies to my tables.
'indexes' => array(
'uid_entered' => array('uid_entered'),
'is_suggestion_is_active_language' => array('is_suggestion', 'is_active', 'language'),
'sid_language_is_suggestion_is_active' => array('sid', 'language', 'is_suggestion', 'is_active')
),
but my table looks like this:
CREATE TABLE `drupal6`.`l10n_community_translation` (
`tid` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
`language` varchar(12) NOT NULL default '',
`translation` text NOT NULL,
`uid_entered` int(11) NOT NULL default '0',
`uid_approved` int(11) NOT NULL default '0',
`time_entered` int(11) NOT NULL default '0',
`time_approved` int(11) NOT NULL default '0',
`is_suggestion` int(11) NOT NULL default '0',
`is_active` int(11) NOT NULL default '0',
PRIMARY KEY (`tid`),
KEY `l10n_community_translation_language` (`language`),
KEY `l10n_community_translation_is_suggestion` (`is_suggestion`),
KEY `l10n_community_translation_is_active` (`is_active`),
KEY `uid_entered` (`uid_entered`),
KEY `is_suggestion_is_active_language` (`is_suggestion`,`is_active`,`language`),
KEY `sid_language_is_suggestion_is_active` (`sid`,`language`,`is_suggestion`,`is_active`)
) ENGINE=MyISAM AUTO_INCREMENT=593 DEFAULT CHARSET=utf8;
To be clear there are 3 keys that I do not see in the schema. What is the correct schema???
KEY `l10n_community_translation_language` (`language`),
KEY `l10n_community_translation_is_suggestion` (`is_suggestion`),
KEY `l10n_community_translation_is_active` (`is_active`),
Should I run the below code by hand - to fix the inconsistency or does the module do this in beta2?
ALTER TABLE {l10n_community_translation} DROP INDEX l10n_community_translation_language
ALTER TABLE {l10n_community_translation} DROP INDEX l10n_community_translation_is_suggestion
ALTER TABLE {l10n_community_translation} DROP INDEX l10n_community_translation_is_active
Comments
Comment #1
gábor hojtsyLooks like your installation was not using the keys as present in alpha5 either. Here is the alpha5 code:
http://drupalcode.org/viewvc/drupal/contributions/modules/l10n_server/l1...
Not surprising that beta1 tries to drop keys with the names used earlier in the schema. Feel free to drop the keys which were improperly named.
Comment #2
hass commentedSorry, but I'm reopen this now. I have always upgraded the available versions and if you break the upgrade path, yes something is broken. The module should fix the bugs. Also done a schema comparison now with schema module and found the following:
I always ran update.php and never added the indexes myself that are now in the DB. Could you fix this with an update hook, please?
Comment #3
hass commented1. Shouldn't be line 540 in l10n_community_update_6000():
db_add_unique_key($ret, 'l10n_community_project', 'l10n_community_project_uri_connector_module', array('uri', 'connector_module'));notdb_add_unique_key($ret, 'l10n_community_project', 'uri_connector_module', array('uri', 'connector_module'));2. unique keys uri_connector_module: missing in database is also correct as the name is wrong.
3. indexes uri: missing in database is definitely missing in schema update hooks if this wasn't inside from the first day.
4. indexes l10n_community_project_uri is possible another type of this copy and past bugs like #1
5. l10n_community_string = FALSE is set in l10n_community_update_6010, but schema DEF says TRUE... looks like I ran this update path. Now - what's correct? FALSE or TRUE? Same for l10n_community_update_6007() - l10n_community_line.type.
6. No idea how this indexes came in... they are wrong?
# indexes l10n_community_translation_is_active: unexpected (not an error)
# indexes l10n_community_translation_is_suggestion: unexpected (not an error)
# indexes l10n_community_translation_language: unexpected (not an error)
Comment #4
hass commentedChanging title as there are more tables and fields inconsistent.
It's very unclear to me if the update hook definitions or the hook_schema definitions are correct. Therefore completely impossible for me to share a patch.
Comment #5
gábor hojtsyFor all 6 cases, consider the schema definition as the base. For 6, we already agreed they are wrong, were named differently by the schema before and were dropped in a recent update function.
Comment #6
gábor hojtsyOk, looked at localize.drupal.org's database, running the schema module against the DB and code running there (added the schema module temporarilty to that site). The only issue it found was this mismatch (no missing or extra stuff found under l10n_server):
The server on localize.drupal.org was continually updated since 6.x-1.0-alpha4 (2009 July 29th) and is now on 6.x-2.0-beta1 (2010 March 22nd). Looks like you've had other issues which localize.drupal.org did not have through all the updates, so I'm reliant on you for reproducing any issues other then this one difference in defaults I could reproduce. Including a fix for this default difference would be straightforward in our code, but beyond that I'm not sure your problems are generally applicable unless reproduced elsewhere.
Comment #7
hass commentedThe absolute basic was 5.x-1.x-alpha1 or so... the site exists for a very long time and was updated from time to time with the official releases. If I'm able to find some spare time I may be able to dig deeper, but I do not like to find all the bugs and their sources. Following many years is out of scope for me. I can only assure you I have never changed the DB myself and I have for sure executed update.php to get all updates and if something have failed you have seen it in the issue queue.
Comment #8
gábor hojtsy@hass: right, since these issues might stem from years ago. Last June this module had about 20 users while currently it hovers around 100. Consider how many users we've had in 5.x-1.x-alpha1 and you'll see that it is probably worthwhile to tell those couple users to fix up their databases by hand instead of putting in conditional DB changes which could cause whack on existing sites if gone wrong. Unless this is reproduced by others, I'm not seeing how actual code changes make more good then the potential bad it can cause.
Comment #9
hass commentedDo you fix #6 in beta3?
Comment #10
gábor hojtsyI plan to fix the one I could reproduce with the hashkey column default (that was #5 on your list). As said, the extra indexes from #6 you can just drop.
Comment #11
hass commentedMaybe someone else also need this... This is what I've executed now to fix all the inconsistencies on MySQL, but this does not yet fix #6.
Comment #12
gábor hojtsyOk, let's try this one to fix the hashkey column. We need to drop the unique key registered to it before and add it after as per the docs for database compatibility.
Comment #14
gábor hojtsyWell, the patch contained bad table names anyway. Let's see whether it can be applied against 2.x.
Comment #15
ClearXS commentedCan someone tell me how to repair database errors reported by some schemes, caused by this module or by other modules, without reinstalling every time again until the next new module or upgrade makes a mess of the database? Is there a course somewhere on the internet I can follow, before one should ever start working with additional modules in drupal?
Comment #16
gábor hojtsyAny feedback on this one?
Comment #17
gábor hojtsyWorked for me, so committed this (updated to latest 2.x-dev).