Thursday, August 2, 2012

Migrating Drupal 6 to WordPress 3

The "Modeling Languages portal" transitioned from Drupal 6 to Wordpress 3 in early 2011.  They had assumed there would be tools for this purpose, but found nothing.  They found a few SQL scripts

http://blog.room34.com/archives/4530

http://socialcmsbuzz.com/convert-import-a-drupal-6-based-website-to-wordpress-v27-20052009/

http://info4admins.com/migrate-convert-import-the-drupal-6-database-to-wordpress-3/

The process used by these scripts is to create database tables for a Wordpress instance in the same database that holds the database tables for the Drupal instance.  The SQL scripts go about an in-place conversion of data from the Drupal database tables to the Wordpress tables.

Based on those the "Modeling Languages Portal" team created a Java program to do a better conversion, still using the same process.

http://modeling-languages.com/wp-content/uploads/DrupalToWordpress.java

Finally, they've set up a service company to do such migrations: http://migratetowp.com/

Turns out that a key thing left out by the scripts above is conversion of the user tables & passwords over to Wordpress users.  The MigrateToWP service company does conversion of user tables & passwords.

http://modeling-languages.com/migrating-drupal-6-to-wordpress-3/


A satisfied customer blogged about the experience here: http://howardowens.com/2011/08/23/migrating-from-drupal-to-wordpress/

The instruction steps for running the Java program should give a flavor for how this conversion process works:


  1. Create your wordpress installation in the same database where you have your Drupal installation (not mandatory but will facilitate things)
  2. Truncate the data in the following WordPress tables: comments, posts, postmetaterm_relationships, term_taxonomy, terms. Delete the users table (if you want to migrate Drupal users) except for the first one (the site administrator)
  3. Clone the taxonomies of categories you had in Drupal.  Basically, data in  term_data is moved to the WordPress table terms and term_hierarchy to term_taxonomy (each row in these two tables represent a parent-child relationship)
  4. Clone the posts.  This involves retrieving data from three drupal tables: node (basic post info), node_revisions (body and teaser) and url_alias (url info) and inserting it into the single posts wordpress table.
  5. Fix the image/files URLs in the posts. Images in wordpress are usually stored in the uploads folder while Drupal stores them in the sites/default/files folder. So, the body content must be updated using a sentence like this one:  body=body.replaceAll(“/sites/default/files/contentImages/”, “/wp-content/uploads/”);
  6. Fix the post URL itself. Drupal stores the full URL while WordPress only the last part (the one corresponding to a url-friendly version of the post title).
  7. Relate posts and categories. Take the relationships in the Drupal tables node and term_node and store them in the term_relationships wordpress table.
  8. Update the category count attribute now that we have inserted the data in term_relationships
  9. Migrate the comments. Quite straightforward, from the comments Drupal table to the comments wordpress table.
  10. Update the comment_count attribute in the posts table (if not comments will not be displayed even if they have been properly inserted in the database).
  11. (not part of the script) Don’t forget to define the redirection rules that will forward all requests to the previous URLs of your drupal posts to the new URLs of your  wordpress ones!! You want people to be able to find your posts!

2 comments:

  1. Very useful article!
    To save your time and money, you may also migrate your drupal site to wordpress automatedly with the help of migration tool. cms2cms performs migrations from 15 minutes - 10 hours migration as to the quantity of your site entities. http://www.cms2cms.com/

    you may watch video tutorial on how to migrate your website from drupal to wordpress https://www.youtube.com/watch?v=im4AfhhfHqc

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete