migrating from mephisto to simplelog
So I managed to teach myself how to use Rails a little, mainly, how to utilize the magic that is ActiveRecord (which unfortunately probably took me at least 48 hours of sustained effort spread out over the last six days.) ActiveRecord makes me almost forget that I’m dealing with a SQL database. I don’t have know any arcane syntax. I just have to know Ruby, which is an extremely Zen-like thing to know. (I know it’s a stereotype, but, damn, you’ve got to hand it to the Japanese.) OK, I’m oversimplifying. I haven’t really gotten the hang of join tables, but its nothing that convoluted kludgery can’t get around.
As an aside, despite the fact that Rails rewards “convention over configuration”, I find it amusing that Typo, Mephisto, and Simplelog all store their data in slightly incompatible ways. You would think that there are really only so many ways to deal with blog entries. Oh well. Such is the open source world, is it not? A wondrous buffet of parts that don’t quite match and which frequently need, uh, retooling. (And yes, I purposefully chose that mismatched metaphor to prove my point.)
Mephisto→Simplelog Conversion Scripts
Well, without further ado, here is my take on a converter from Mephisto to Simplelog. It has been tested exactly once, with the apparently successful migration of my entries and comments from Mephisto to Simplelog without too much bloodshed. Still, you have been warned.
Download: mephisto_to_simplelog.tar.gz
This code is released under the GPL version 2.
Untar this file in $RAILS_ROOT, i.e., the top level directory of the Simplelog application.
cd /path/to/simplelog
tar xvfz /download/directory/mephisto_to_simplelog.tar.gz
Due to historic accident and sheer laziness, the converter is split into two files: mephisto.rb
and mephisto_comments.rb
. The former only imports articles and tags. The latter only imports comments, and will only work after you’ve run the former.
Instructions
-
Make sure you’ve at least installed the database schema for Simplelog. If you don’t know what this means, just install Simplelog as described on the Simplelog wiki. Once the schema is in place, I recommend backing it up so you don’t have to go through the whole process again in case the converter nukes it.
-
Import your articles and tags: ` ./script/runner db/importers/mephisto.rb `{: .block}
-
Import your comments: ` ./script/runner db/importers/mephisto_comments.rb `{: .block}
I would highly recommend running this only on an empty Simplelog install, although I will admit that I ran it on an install that already had a few entries in it. Hopefully you remembered to backup your database, right?
NOTE: You have to have unique permalinks, otherwise the comment importer may not work reliably. The way I wrote it, it isn’t possible to import entries that have the same permalink, but the script can be easily hacked to get around this by deleting a few choice lines.
Other Known Issues
-
I forgot that Mephisto stores times in UTC, and Simplelog seems to use localtime. I haven’t investigated this thoroughly, but suffice it to say that there is a time discrepancy between the entries from Mephisto and the entries that I’ve created using Simplelog.
-
All your tags that used to have punctuation in them will no longer have said punctuation. This is apparently the way Simplelog wants it, and you’d have to muck around with the code to make it otherwise.
-
There is no migration of assets because, well, Simplelog doesn’t manage assets.
-
While the basename of your permalinks (the so-called slug) should be preserved exactly, your path names will change. Whereas Mephisto favors
http://domain.name/archives/yyyy/mm/dd/slug
, Simplelog favorshttp;//domain.name/past/yyyy/mm/dd/slug
. Nothing that a little tweaking of.htaccess
orconfig/routes.rb
can’t fix.
Miscellaneous
The class definitions for Mephisto live in the mephisto/
subdirectory, which contain the bare minimum code to be able to access a Mephisto database via ActiveRecord. If you want to play with them while running ./script/console
, you can just require 'db/importers/mephisto_requires.rb'
.