[Drupal] Drupal 6 to Drupal 7 Migration step 3 - Drupal 6 core major version update.

| | 2 min read

This is probably the part that will crash your site, so proceed with extreme caution! Migration actually starts here. Unlike the previous steps you will not be able to use drush to overwrite your core to Drupal 7. This has to be done manually. You have to download the latest stable version of Drupal 7 and paste into the root folder of your website. Make sure to not overwrite .htaccess and robots.txt. When you overwrite, merge into the folders and replace the files. That being said, there are some prerequisites to this step.

Before you start with this step, make sure you have disabled all non-core modules. Updating without disabling the modules will definitely crash your site as the core modules that have dependency with non-core will throw errors; This happens after Drupal 7 core update, when the enabled non-core modules look for Drupal 6 core modules, they find Drupal 7 core instead!

Disable you non-core modules using drush command coupled with the xargs command :

drush pml --no-core --status=enabled --type=module --pipe | xargs drush dis -y 

Here the output for the drush command is piped as input to the drush command preceding xargs command.

After you have executed this command, you will get an output of all the modules disabled. Run drush pml --no-core --status=enabled --type=module to check whether all non-core modules have been disabled. Disable the rest manually if any remaining which is unlikely.

This is your cue to overwrite core without overwriting the .htaccess and robots.txt. Be sure to backup code and database before updating core. Run update.php to update database.

Running update.php may throw a few errors which is expected and can be solved. The first of which may be :


Failed to CREATE a test table on your database server with the command CREATE TABLE {drupal_install_test} (id int NULL). The server reports the following message: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'drupal_install_test' already exists.
Are you sure the configured username has the necessary permissions to create tables in the database?

This is because it is not a fresh installation but Drupal install treats it like one. All you have to do is remove this table which is just a test table created by Drupal during its first install to see if it has permissions. Use either cpanel or mysql command line to remove the table 'drupal_install_test'.

Now run update.php, the core should update without any issues if the permissions to settings.php file has been granted and $update_free_access = TRUE; has been set in your settings.php file. If you are using git, the settings.php file is probably in .gitignore. The time taken to update depends on the amount of content in your site(articles, pages etc). Your Drupal core is now updated to Drupal 7. The next step is to update all the contrib modules to Drupal 7.