Migrate from Mephisto to Drupal


in

I’m currently working on migrating from a mephisto blog to a Drupal system. It’s not done yet, but so far it was quite easy. However, there was one problem. Exporting the content database table to CSV directly turned out to be not working at all. So I prepared a SQL statement to format the data in a way that can be read and used by the Node Import plugin when exported as CSV.

Note: It’s a little sad, but this does not touch anything besides articles. No comments, no users, no assets.

SELECT
  CASE user_id WHEN 2 THEN "User 1" WHEN 3 THEN "User 2" ELSE "Unknown" END AS author,
  BINARY title AS title,
  CONCAT(DATE_FORMAT(created_at, "articles/%Y/%c/%e/"), permalink) AS permalink,
  BINARY IF(STRCMP(excerpt, ''), CONCAT_WS('<!--break -->', excerpt_html, body_html), body_html) AS body,
  created_at
FROM `contents`
WHERE type = "Article"
ORDER BY created_at

BTW: That BINARY statement is pretty handy if you (like in my case) have the UTF-8 multi byte characters stored as funny looking separated latin1 characters.