Completing the Drupal 7 Upgrade

In my previous blog entry, I mentioned that there was an error thrown during the Drupal 7 upgrade process for the Statistics module. Since I've been delving into the database to fix a problem with the Views module (which will probably my next blog entry), I figured it was time to do a quick look for a solution as it was most likely also a database issue.

Today I finally solved this problem. To be exact, this was the error I was getting:

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 2957 of /disk2/www/drupal7/includes/database/


I found this post under the Drupal Core issues forum - d6 to d7 statistics module update fails 'Specified key was too long'

Reading through the comments I learned that this was caused by some index settings in the table. Because you don't always know what will happen when you edit a database like that, I did a complete db export before starting. Then I was able to easily fix the problem by running the following sql statements in PHPmyAdmin:

ALTER TABLE accesslog DROP INDEX accesslog_path_sid;
ALTER TABLE accesslog DROP INDEX accesslog_uid_sid;

Though apparently I didn't need the second one of those. Then I was able to run the update script with no errors and activate the core statistics module.