
Upgrading Rails One Version at a Time
People are afraid of Rails upgrades mostly because of load_defaults, nobody remembers what it changes, so we booted the configuration in Rails 8.1 with the defaults of each version and compared them line by line, ignoring one object which differs only by its memory address.
Honestly we were waiting for another picture. 7.0 against 7.1 gives 19 changed settings, there you find the new cache format and the message serializer and the HTML5 sanitizer and query log tags format and so on, this one is fat. 7.1 against 7.2 only 4, yjit becomes on and webp goes into web images. 7.2 against 8.0, and here we looked on the screen like stupid, one, strict_freshness and nothing else. 8.0 against 8.1 is 7 again, path relative redirect jumps from log to raise there, so your page which was just complaining now can break. So don't judge the pain by version number, and about gems and deprecations we can't say anything, we didn't count them.
What we do with this list: upgrade the gem first and keep old load_defaults, deploy, then run bin/rails app:update, it writes the new_framework_defaults file with everything commented, and we open one line, deploy, look, next line. The cache format and the serializer we leave for the end, because while rolling deploy the old and the new processes are reading data of each other, and when all lines are open we move load_defaults and delete the file.
bin/rails app:update
Before starting we also make deprecations loud in the test environment, it costs nothing on the old version and the list of work becomes visible.
# config/environments/test.rb
config.active_support.deprecation = :raise
config.active_support.disallowed_deprecation = :raise
config.active_support.disallowed_deprecation_warnings = [
"Passing a block to ActiveRecord"
]
See also: Our notes on safe migrations and still the right stack and how we keep a team's Git history sane.