Reputation: 139
I'm looking for a recommended path for a Ruby on Rails application running on Ruby 2.3.8
and Ruby on Rails 4.2.11
to the latest stable versions of Ruby and Ruby on Rails. What is the safest and most stable option for a very large codebase?
2.4
, then 2.5
and so on, and then come back to upgrading Rails in small steps (e.g., 4.2
=> 5.0.x
=> 5.1.x
=> …)?4.2.x
?Any recommendations and guidance would be greatly appreciated.
Upvotes: 6
Views: 2042
Reputation: 107067
The first step is to make sure that your application has enough tests to give you confidence during upgrading the application.
Then you can start the actual upgrade process. There are different ways to do this. I usually suggest updating in smaller steps, instead of huge all in once upgrades, because that makes it much easier to fix issues along the way because you know exactly with Ruby or Ruby on Rails version introduced the issue.
Additionally, each Ruby on Rails version has a range of Ruby versions they are compatible with, and you have to update them in matching combinations.
Some people propose that you should upgrade to the lowest minor and patch version first and then to the latest minor, for example, like 5.0.7.2 -> 5.1.0 -> 5.1.7
. But in my experience, it is fine to update directly to the latest version of the next minor version, like 5.0.7.2 -> 5.1.7
.
I recommend following this table with Ruby and Ruby on Rails compabilities. This leads to the following upgrade path:
ruby 2.3.8 rails 4.2.11 your current versions
|
ruby 2.3.8 rails 4.2.11.3
|
ruby 2.3.8 rails 5.0.7.2
|
ruby 2.4.10 rails 5.0.7.2
|
ruby 2.4.10 rails 5.1.7
|
ruby 2.5.9 rails 5.1.7
|
ruby 2.5.9 rails 5.2.8.1
|
ruby 2.6.10 rails 5.2.8.1
|
ruby 2.6.10 rails 6.0.6.1
|
ruby 2.6.10 rails 6.1.7.10
|
ruby 2.7.8 rails 6.1.7.10
|
ruby 3.0.7 rails 6.1.7.10
|
ruby 3.0.7 rails 7.0.8.7
|
ruby 3.1.7 rails 7.0.8.7
|
ruby 3.2.7 rails 7.0.8.7
|
ruby 3.2.7 rails 7.1.5.1 minimum combination to still get security fixes
|
ruby 3.3.7 rails 7.1.5.1
|
ruby 3.3.7 rails 7.2.2.1 minimum combination to still get bug fixes
|
ruby 3.3.7 rails 8.0.1
|
ruby 3.4.2 rails 8.0.1
Note that at the time of the last update of this answer (November 2024) Ruby 3.1 and Ruby on Rails 7.1.x still get security fixes. Therefore, I would suggest that to be the lowest version combination to run on production. Bug fixes are only available for Ruby 3.2 and Ruby on Rails 7.2.x and above.
During each step, consult Upgrading Ruby on Rails in the official Rails Guides about what changed in that specific version. After each step, make sure to fix all deprecation warnings that might occur.
Please keep in mind reviewing all your other gems too. I would consider it a good practice to update all gems to the latest versions that are compatible with your current Ruby and Ruby on Rails combination after each step and before making the next upgrade step.
Upvotes: 14