Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I get the following error when updating to drupal 7.
It's a test installation, but I'm using database from production website.
Update #7201
Failed: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: ALTER TABLE {votingapi_vote} CHANGE `content_type` `entity_type` VARCHAR(255) DEFAULT NULL; Array ( ) in db_change_field() (line 2888 of C:\Program Files (x86)\EasyPHP-5.3.4.0\www\includes\database\database.inc).
Comments
Comment #2
eaton CreditAttribution: eaton commentedAfter some quick investigation, it appears that the update hook was incorrectly specifying a larger column length than hook_schema. While I'm not sure how the above error message would result, the latest dev release has a fix for this and it should be in the upcoming final release. Thanks.
Comment #3
FlowerOS CreditAttribution: FlowerOS commentedNo. Not even the dev version works. Same error.
Failed: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: ALTER TABLE {accesslog} CHANGE `sid` `sid` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'Browser session ID of user that visited page.'; Array ( ) in db_change_field() (line 2888 of /home/httpd/html/website/includes/database/database.inc).
Comment #5
johannesjvorstermans CreditAttribution: johannesjvorstermans commentedwell it is not fixed. I am getting:
The following updates returned messages
statistics module
Update #7000
Failed: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: ALTER TABLE {accesslog} CHANGE `sid` `sid` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'Browser session ID of user that visited page.'; Array ( ) in db_change_field() (line 2888 of /var/www/drupal-sites/drupal-7.0/includes/database/database.inc).
Comment #6
don@robertson.net.nz CreditAttribution: don@robertson.net.nz commentedI am getting a similar error, but do not get as far as an update number.
Comment #7
Virgil CreditAttribution: Virgil commentedSame error here.
Comment #8
smscotten CreditAttribution: smscotten commentedI've got this reported as update #7201
I took a look at the indexes in the table, and the longest one is "content_vtype_tag_func" which is made up of content_type (length 20), content_id (length 10), value_type (length 20), tag (length 128), and `function` (length 128). I (somewhat arbitrarily) limited tag and function to 100 characters (in the indexes, not the table field definition) and reran the uipdate, yielding the following:
My assumption here is that the field names were actually changed prior to the "key too long" error. Sure enough, votingapi_vote had the specified field names changed. So I changed entity_type back to content_type and entity_type back to content_type in votingapi_vote (votingapi_cache did not have the names changed) and reran. The update ran successfully.
I suggest looking at Matthew Lord's explanation at http://bugs.mysql.com/bug.php?id=6604 and limiting the lengths of the keys used to make indices. I suspect that those long indices are a drag on performance anyhow, but I don't know—they could be necessary or coding standards might contraindicate my suggestion.
This could be a problem, because the tables would have to be changed prior to this update, which means just tacking the change on as update #7202 won't cut the mustard. In any case, my tale here should indicate a workaround for anyone unafraid to manually mess with their db index definitions.
Comment #9
smscotten CreditAttribution: smscotten commentedAlso, anyone getting "ALTER TABLE {accesslog}" or any table name other than "ALTER TABLE {votingapi_cache}" should look at #1261056: d6 to d7 statistics module update fails 'Specified key was too long' as it's not something related to the votingapi module.
Comment #10
ikke CreditAttribution: ikke commentedthx smscotten - this was very helpful :)
Comment #11
Senpai CreditAttribution: Senpai commentedThe problem described in comment #1 is still occurring with votingapi v2.6, wherin the changing of a field in the votingapi_vote or votingapi_cache tables results in a fatal error:
The attached patch properly checks for the existence of the old fields before attempting to safely rename them. It does not fix the
1071 Specified key was too long
error, however.At least this patch will allow the true error to surface each and every time the update hook is run instead of masking the real error with another fake error. :) I'm still working on the "key too long" problem, and I need to find a solution quickly, so if anyone has ideas, fire away.
Comment #12
Senpai CreditAttribution: Senpai commentedComment #14
Senpai CreditAttribution: Senpai commentedSo here's what we had to do in order to get this module to upgrade itself from D6 to D7. Yeah, it's a lot, but at least it works now. :) I recommend not putting this patch into the module as a "fix", but instead addressing the invalid key lengths.
Just attaching this patch to the issue in case someone else needs a solution to get themselves migrated into D7.
(All code by @dankessler)
Comment #15
betarobot CreditAttribution: betarobot commented#14 worked just fine for me. Cheers @Senpai
Comment #16
berenddeboer CreditAttribution: berenddeboer commented#14 fixed my problems too.
Comment #17
julien66 CreditAttribution: julien66 commented#14 rocked here too. Thxs.
Comment #18
iStryker CreditAttribution: iStryker commentedok 3 people confirm #14 works. Marking as RTBC
Patch still applies cleaning, minus 1 line of whitespace and offset of 38 lines.
Eventhough no one is upgrading from 6.x to 7.x any more, I still think this is critical.
Attach is the patch #14 minus the whitespace and the update to date 7.x-2.x-dev. This patch passes coder too.
Comment #19
hass CreditAttribution: hass commentedPatch #18 fixes the upgrade for me, too. THX
Comment #20
torotil CreditAttribution: torotil commentedCould someone please send me a failing D6 database dump? I'd like to give it a closer look than just commiting #14.
Comment #21
torotil CreditAttribution: torotil commentedFix commited in 7.x-2.x http://drupalcode.org/project/votingapi.git/commit/60694cb .
Comment #22
hass CreditAttribution: hass commentedHas someone verified with schema module if the schema matches 100% now?
Comment #24
dasrajarshi CreditAttribution: dasrajarshi commentedPDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: ALTER TABLE {sessions} ADD PRIMARY KEY (`sid`, `ssid`); Array ( ) in db_add_primary_key() (line 2891 of D:\Program Files\Zend\Apache2\htdocs\knmupgrade\includes\database\database.inc).
Comment #25
hass CreditAttribution: hass commentedComment #26
hass CreditAttribution: hass commentedComment #27
torotil CreditAttribution: torotil commentedI don't see how the last error can come from a votingapi update. It seems to deal with the core-session table. Note that drupal assumes that you are using the InnoDB DB-Engine - this error seems to come from a MyISAM table.
Comment #28
Rosamunda CreditAttribution: Rosamunda commentedUpdating from 6 to 7.2.11 gets this error:
Comment #29
torotil CreditAttribution: torotil commented@Rosumanda: Please don't post different cases to already closed issues.
It seems that you've already attempted the upgrade to D7 but it failed for some other reason. If the problem persists please open a new issue.
Comment #30
Rosamunda CreditAttribution: Rosamunda commentedSorry about that.
As I read that this issue was related to Update #7201 I thought in reopening this one instead of creating a (maybe, somewhat) duplicate new one.
I´ll post a new issue.
Thanks! :)