# this script is modified after the recipe provided at # http://spindrop.us/2006/05/19/migrating-from-drupal-47-to-wordpress # # updated 2007/05/28 with the comment count updater script from # http://www.brendanloy.com/2007/02/wordpress-21-upgrade-problems.html # # updated 05-03-2009 door Vincent Kouters # http://www.vincentkouters.nl/overstap-van-drupal-5-naar-wordpress-2-migratieproblemen # # this assumes that both wordpress and drupal are in the same databases. # The wordpress database is called "naam_database" # first, nuke previous content in wordpress database use naam_database; delete from wp_posts; delete from wp_comments; delete from wp_terms; delete from wp_term_taxonomy; delete from wp_term_relationships; # posts INSERT INTO wp_posts (id, post_date, post_content, post_title, post_excerpt, post_name, post_modified) SELECT DISTINCT n.nid, FROM_UNIXTIME(created), body, n.title, teaser, REPLACE(REPLACE(REPLACE(REPLACE(LOWER(n.title),' ', '_'),'.', '_'),',', '_'),'+', '_'), FROM_UNIXTIME(changed) FROM naam_database.node n, naam_database.node_revisions r WHERE n.vid = r.vid; # comments INSERT INTO wp_comments (comment_post_ID, comment_date, comment_content, comment_parent, comment_author, comment_author_email, comment_author_url) SELECT nid, FROM_UNIXTIME(timestamp), comment, thread, name, mail, homepage FROM naam_database.comments ; # update comments count on wp_posts table UPDATE `wp_posts` SET `comment_count` = (SELECT COUNT(`comment_post_id`) FROM `wp_comments` WHERE `wp_posts`.`id` = `wp_comments`.`comment_post_id`); # fix post slugs. first we have to remove the duplicate _____ chars, then replace that with a single - char UPDATE wp_posts set post_name = REPLACE(post_name, '__', '_'); UPDATE wp_posts set post_name = REPLACE(post_name, '__', '_'); UPDATE wp_posts set post_name = REPLACE(post_name, '__', '_'); UPDATE wp_posts set post_name = REPLACE(post_name, '__', '_'); UPDATE wp_posts set post_name = REPLACE(post_name, '_', '-'); # tags en categorien (drupal) naar tags (WP) INSERT INTO naam_database.wp_terms(term_ID, name, slug) SELECT term_data.tid, name, lower(replace(name,' ','-')) as slug FROM naam_database.term_data ; insert into naam_database.wp_term_taxonomy (term_taxonomy_id, term_id) SELECT term_data.tid, tid FROM naam_database.term_data ; update wp_term_taxonomy set taxonomy ="post_tag" where taxonomy = ""; INSERT INTO naam_database.wp_term_relationships(object_id, term_taxonomy_id) SELECT term_node.nid, tid FROM naam_database.term_node; # optioneel - leegmaken van de samenvatting update wp_posts set post_excerpt="";