Upgrading from Drupal 4 to Drupal 6 - setting up the environment

Tue, Jul 28, 2009 by Alla

Upgrading from Drupal 5.x to Drupal 6.x can be painful, but not as painful as upgrading from Drupal 4.x to Drupal 6.x. This is a 3 part blog series to guide you through the upgrade process from Drupal 4.x to Drupal 6.x.

Upgrading from Drupal 4 to Drupal 6 cannot be done in 1 step. You have to upgrade your current Drupal 4 and contributed modules to the latest versions, and only after this from Drupal 4.x to Drupal 5.x and then from Drupal 5.x to Drupal 6.x. Moreover, there are plenty of sub-steps that have to be implemented during each of these two big upgrades. The reason for this is that you are not only updating your Drupal site's code, but, the most importantly - the database. The more contributed modules you use, the more steps you are going to have. The database tables structure may have changed several times from one module's version to another. It is very important that these changes are done in some particular order, especially if you have lots of dependencies between them. So, the longer you wait - the more painful upgrade is going to be.

Some contributed modules that were used for Drupal 4 don't exist for Drupal 5 or 6. Some of them (or more specifically, the db tables where the data for these modules was saved) can be converted for appropriate new modules using some converter modules. Hopefully, you will find the reference to the converter you need on you old module's page, see for example http://drupal.org/project/flexinode: "If you used Flexinode in the past and want to migrate to use CCK consider using the Flexiconvert project."

There are quite a lot of pages describing the process in details, but here is the link to the main one: http://drupal.org/upgrade. You will see lots of references to other pages there, including Updating Modules and Converting a Theme to a Later Drupal Version - read them! You will have to read a lot for a smooth flow ;-)

Here I want to describe our process in general, starting with Preparations:

1. I organized SVN repository for our needs. (Here I assume that you already know how to work with SVN. If not - please see http://svnbook.red-bean.com/en/1.0/ and http://subversion.tigris.org/).
Besides the ourproject/trunk, which we are going to need only later, I created 3 branches within the project - one for each Drupal version: ourproject/branch/drupal4, ourproject/branch/drupal5, ourproject/branch/drupal6. Technically, this is not exactly "branches" as they are usually termed in SVN. It's more like 3 separate sub-projects grouped in one folder, but I don't think it is important how you organize this. What I want to say is that you need to be able to make 3 check-outs for 3 working copies on your work computer for each Drupal version.

2. In my working folder I checked out (and created) 3 folders: work/drupal4, work/drupal5, work/drupal6.

3. In hosts file, added records for 3 domains: ourproject_d4.localhost, ourproject_d5.localhost, ourproject_d6.localhost

4. Added Apache virtual hosts for these domains, pointing DocumentRoot's to my work/drupal4, work/drupal5 and work/drupal6

5. Added the original code from our current to-be-converted Drupal 4 site to work/drupal4 directory, committed changes to SVN repository (the folder already pointed to the ourproject/branch/drupal4)

6. Downloaded everything we are going to need - the latest versions of Drupal 4.7.x, of Drupal 5.x and 6.x, the latest versions of all contributed modules for Drupal 4/5/6 that we currently have in our site. As you start upgrading, you will see the other modules you are missing and you will add them later. In Drupal 4, you can see the names of your contributed modules in the /modules directory - unlike core modules, they are all in sub-folders.

7. Added the code for Drupal 5 to work/drupal5; for Drupal 6 to work/drupal6. Committed changes to SVN repository (the folder already pointed to the ourproject/branch/drupal5 and ourproject/branch/drupal6)

8. Imported my current database to db_4, created empty databases db_5 and 6. Pointed each setting.php to the corresponding DB.

At this point I have 3 web sites - the ourproject_d4.localhost was a replica of the current Drupal 4 site, ourproject_d5.localhost and ourproject_d5.localhost just bare Drupal sites.
The idea is to make it easy to repeat a consequent database transformations through Drupal 4-5-6 and to be able to add changes to the code, add/remove back and forth the contributed modules if you think you need to change the order in which you add modules. When the db for the Drupal 4 is upgraded (to be described later), you either copy it to the next DB (db_5) or export/import it to the db_5 - it's up to you. You also can point all your 3 Drupal sites to the same DB and do the upgrade consequently on ourproject_d4.localhost-> ourproject_d5.localhost-> ourproject_d6.localhost - it's up to you, whatever is less confusing for you. Just do not forget to create DB dumps after every step - it will make your life easier if you make a single mistake.

The Transformation just begins here...

Sam Hunting posted on August 10, 2009 3:46 pm

Good article. I'd add that in my experience, it's also handy to be able to swap in PHP4 when working with D4. On OS X, Mamp makes that easy. And, since this seems like the setup phase of the conversion process, it might be step 0.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <h2>
  • Lines and paragraphs break automatically.

More information about formatting options