2. Preparing to upgrade

Importance of testing

After having studied the new Rails features and possible breaking changes, in most cases you would have a pretty good understanding of the areas requiring your attention. That’s a good time to check your test coverage and make sure the critical parts of your application are well tested.

Fighting gem dependencies

The first thing to do before starting any upgrade is to check your Ruby Gem dependencies. If you aren’t Basecamp, you probably use a bunch of gems that extend the functionality of your app beyond the Rails’s “default backpack”. And frankly, this is the most annoying part of any upgrade process— fighting with software dependencies.

It’s that time when you find the library you’ve been using is no longer maintained, or when you start feeling “unsafe” by linking Git repositories directly in your Gemfile.

Bundler does a good job figuring out the versions you need to satisfy your gem dependencies. In most cases, though, you would need to reference the GitHub’s master or rails5 branches. I hope the latter is becoming a convention in the community, which is really a neat way to let developers know whether the particular library works towards the next major Rails release.

If you found that particular gem is no longer maintained or you don’t want to wait for it to be “ready”, you would need to start looking for a replacement or writing your own implementation. This reminded me of an excellent post by ThoughtBot’s Elle Meredith — To gem or not to gem.

In any case, be sure to check the CHANGELOGs and commit histories of the gems you’re using. There might be more breaking changes that will add up the time to your upgrade process.

Allocating time

Another important decision to make is how and when to take the time for the upgrade. Without going into too many details, which are anyway team/app specific, what worked well for the teams I worked with is doing it on the side, as opposed to one-shot migration.

For bigger apps, it’s less risky and your estimation of “hey, it will just take me a couple of days” is most probably wrong. By the way, is that what we always tell before every major software rewrite? 😉 We simply can’t be aware of all the pitfalls, which is one of the things that makes me love the nature of software development —isn’t it adventurous?!

If you found the upgrade process would take much longer, it sometimes makes sense to invest in making your app “cluster” ready, meaning that you can run multiple versions of the app simultaneously. This would allow you to use and test the new version internally, even before it’s shipped to your users.