Missing Mephisto Upgrade Guide: 0.7.3 to 0.8

Wow! This takes me back! Please check the date this post was authored, as it may no longer be relevant in a modern context.

My Mephisto install was 0.7.3- 0.8 doesn’t have any huge feature changes but there are some bugfixes and small enhancements, as well as a performance boost (speed, memory use) from using rails 2.0. My install was from a tarball, and I don’t want to move my production server to a git checkout (yet?). Like other Mephisto users I’ve got theme customizations and maybe even some things in the public directory.

I need to upgrade, not reinstall. The Mephisto folks didn’t write a real upgrade guide, but this is Rails and it’s not too hard to figure out. Almost any rails app could be updated this way:

  • Back Everything Up
  • Create & Apply A Patch
  • Stop Your Server & Clean Up
  • Patch Code & Migrate The Database
  • Crack Open A Beer

Back Everything Up

Back up the current code and database.

cp -a my_blog my_blog.bck
mysqldump -uroot --opt mephisto_production > pre0.8.sql

There’s your safety net.

Create A Patch

The trick here is to create a patch between the version of Mephisto you’re currently running and 0.8. For me that was 0.7.3, so that’s what I’ll use below. Fetch the 0.7.3 and the 0.8 source:

wget http://s3.amazonaws.com/mephisto-blog/mephisto-0.7.3.tar.gz
wget http://github.com/technoweenie/mephisto/tarball/master.tar.gz

And this is weird right here. Justin has linked the 0.8 release from the Mephisto download page as the git master tarball. This means you don’t know what rev of git you will actually get when you click on it.

So there isn’t even really an 0.8 release, there’s just a link to a dynamic current master. Bad form.

I ended up with 9072b487bf45c5e41e33c66b32d94aea84732d1b, you might get something else. You could get the rev I used by fetching it directly:

wget http://github.com/tarballs/technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b.tar.gz

Now untar the two packages. You get a nice “mephisto-0.7.3” directory for 0.7.3, and something messy like “technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b” for 0.8. Make a diff between the two:

diff -Nur mephisto-0.7.3 technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b > ~/mephisto-0.7.3_to_0.8.patch

Or you can download the 0.7.3 to 0.8 patch from me, it weighs in at a hefty 4.9M.

Stop Your Server & Clean Up

Everyone has a custom Rails setup, so just stop your server the proper way. After that give it a good:

rake tmp:clear

To flush out the caches and such.

Patch Code & Migrate The Database

Now that the server is turned off and cache is cleared, try patching.

cd /var/ww/my_blog
patch -p1 < ~/mephisto-0.7.3_to_0.8.patch

Mostly you’ll just see “patching file ….” flying by, but you may get a changed file question like this:

patching file public/.htaccess
Reversed (or previously applied) patch detected!  Assume -R? [n]

You can likely answer “n” to both the Assume and the Apply question:

patching file public/.htaccess
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file public/.htaccess.rej
patching file public/install.html
...

I also had some custom filters added to environment.rb, and got this:

patching file config/environment.rb
Hunk #3 FAILED at 44.
1 out of 3 hunks FAILED -- saving rejects to file config/environment.rb.rej
patching file config/environments/development.rb
...

A failed hunk means patching that file didn’t work, usually because you have local modifications. In case the solution is easy: You want to use the version of config/environment.rb that came with 0.8, and put your customizations into config/initializers/custom.rb. Copy the good config/environment.rb from the 0.8 tarball you extracted earlier right over the local file. You can still find your customizations in config/environment.rb.orig and copy them from there to the new file for environment customizations, config/initializers/custom.rb.

Install Gems (Well, I Had To)

Before I could migrate I had to install tzinfo.

sudo gem install tzinfo

Maybe you will too.

Migrate The Database

Compared to applying the patch this is easy:

cd /var/www/my_blog
RAILS_ENV=production rake db:migrate

My database updated with no problems at all.

Crack Open A Beer

Start up your mongrel, thin, eventd_mongrel or other server and crack open that frosty brew. You’ve just upgraded yourself to the best release of the self-proclaimed best blogging system ever.

So what kind of beer are you enjoying today?