Switched from Drupal 5 to WordPress 2.5

After having trouble with the Drupal upgrade I decided to give WordPress a try. The funny thing is to copy the existing posts to the new tables. If you got the same problem, you can use this view:

CREATE VIEW wp_import AS SELECT a.nid AS ID, 1 AS post_author, FROM_UNIXTIME(a.created) AS post_date, FROM_UNIXTIME(a.created) AS post_date_gmt, b.body AS post_content, b.title AS post_title, 0 AS post_category, b.teaser AS post_except, ‘publish’ AS post_status, ‘open’ AS comment_status, ‘open’ AS ping_status, ” AS post_password, ‘post’ + a.nid AS post_name, ” AS to_ping, ” AS pinged, FROM_UNIXTIME(a.changed) AS post_modified, FROM_UNIXTIME(a.changed) AS post_modified_gmt, ” AS post_content_filtered, 0 AS post_parent, a.nid AS guid, 0 AS menu_order, ‘post’ AS post_type, ” AS post_mime_type, 0 AS comment_count FROM node a JOIN node_revisions b ON a.nid = b.nid WHERE a.type = ‘blog’ AND a.nid > 1 AND a.status = 1;

Then you can easily import all your stuff (without the images, sorry):

INSERT wordpress.wp_posts SELECT * FROM wp_import;

Wanna convert your custom markup to HTML? No problem, just run this query (works for cached content only, so you might want to click on each of your older posts once as a quick fix):

UPDATE wordpress.wp_posts w, (SELECT a.nid, b.data AS filtered FROM node_revisions a, cache_filter b WHERE CONCAT_WS(‘:’, a.format, MD5(a.body)) = b.cid) AS c SET post_content = c.filtered WHERE c.filtered IS NOT NULL AND w.ID = c.nid;

There might be a way to import a Drupal blog via RSS as well – let’s see if somebody answers to my posting on the WordPress support forum.

Update (6.5.2008)

I found another blog post that explains how to migrate from Drupal 5 to WordPress 2.0. The provided SQL script also converts categories and comments, which mine does not. However, it does not care about input filters, so Wikicode will not be converted to HTML. The perfect solution would be a combination of our scripts ;)