I’ve just finished moving my blog from running on Serendipity to a Drupal installation. Drupal seems a lot more stable and more customisable. Serendipity was only really a blog, but Drupal is a full content management system so I thought it might be a better idea to learn how it works!
Of course the trouble is I have quite a few articles written in serendipity and I needed to be able to transfer them easily. After searching around on the net, the only reference I could find was a dead link to an SQL script. Oh well, guess I’d better write my own. Read on for the instructions.
The main assumption here is that both Drupal and Serendipity are on the same server, with the same database. Its not a big deal if they are on different databases, its just that mine were and that how I’ve done the script. The other assumption is that all the articles are by the same user, and that they are all going to be going under a single user on the Drupal installation (UID 1). If you have multiple users, then it is still possible, but it would add another layer of complication to the script. If anyone needs some help, just give me a shout. Lastly, there should be no stories already in the Drupal database (ie. a fresh install)
In this script the Serendipity tables are prefixed serendipity_, and the Drupal tables are prefixed drupal_. In Serendipity, all the content is stored in one table, entries, whilst in Drupal they are split across two tables, node and node_revisions. Below is the script that will take all entries from serendipity_entries and place the relevant information in the correct tables for Drupal. The commands can be either run via the mysql command line, or in phpMyAdmin.
drupal_node(vid, type, title, uid, status, created, changed, comment, promote, moderate, sticky, tnid, translate)
SELECT id, 'story', title, '1', '1', timestamp, timestamp, '2', '1', '0', '0', '0', '0' FROM serendipity_entries;
drupal_node_revisions(vid, uid, title, body, teaser, timestamp, format)
SELECT id, '1', title, extended, body, timestamp, '2' FROM serendipity_entries;
Thats all it takes. All these entries should now be published under UID 1 in Drupal as stories with the original timestamp, promoted to front page, and full HTML enabled. If you don’t want the entries on the front page, change the third ‘1’ to a ‘0’ on the first bit of SQL. Change the second ‘1’ to a ‘0’ if you don’t want them published automatically.
I hope this can help someone.
Please follow and like us: