# RUBY/RAILS UPGRADE (WRITE AN INTRODUCTION WITH GENERAL ADVICE ON UPDATES) We came up with two options on how to progress with the Rails/Ruby update. The current context: ruby 2.5.8 (Released on 21/03/2020) rails: 5.1.6 (Released on: 29/03/2018) **PRE STEP:** Analyze the gem versions(other than Rails) to list which ones we want to update and to which versions. This particular detail can be negotiated within each step of the upgrade. Nonetheless, a guideline to follow is to split each gem update into a different commit so we make sure the CI is always happy and to facilitate any possible reverts. Some articles on that subject: https://thoughtbot.com/blog/keep-your-gems-up-to-date https://depfu.com/blog/2017/04/25/bundlers-new-update-options ## First Option: More conservative ### Step 1: **Upgrade Ruby from 2.5.8 to 2.5.9.** 2.5.9 is the latest release before the 2.6 version. Release Note: Date: 05/04/2021 https://www.ruby-lang.org/en/news/2021/04/05/ruby-2-5-9-released/ **Upgrade Rails from 5.1.6 to 5.2.8.1.** 5.2.8.1 is the latest release before the major version change to Rails 6. Release Notes: Version 5.1.7 Date: 28/3/2019 https://rubyonrails.org/2019/3/28/Rails-5-1-7-has-been-released Version 5.2.0 Date: 9/4/2018 https://rubyonrails.org/2018/4/9/Rails-5-2-0-final Version 5.2.1 Date: 7/8/2018 https://rubyonrails.org/2018/8/7/Rails-5-2-1-has-been-released Version 5.2.2 Date: 4/12/2018 https://rubyonrails.org/2018/12/4/Rails-5-2-2-has-been-released Version 5.2.3 Date: 28/3/2019 https://rubyonrails.org/2019/3/28/Rails-5-2-3-has-been-released Version 5.2.4 Date: 27/11/2019 https://rubyonrails.org/2019/11/27/Rails-5-2-4-has-been-released Version 5.2.5 Date: 26/3/2021 https://rubyonrails.org/2021/3/26/marcel-upgrade-releases Version 5.2.6.2 Date: 11/2/2022 https://rubyonrails.org/2022/2/11/Rails-7-0-2-2-6-1-4-6-6-0-4-6-and-5-2-6-2-have-been-released Version 5.2.6.3 Date: 8/3/2022 https://rubyonrails.org/2022/3/8/Rails-7-0-2-3-6-1-4-7-6-0-4-7-and-5-2-6-3-have-been-released Version 5.2.7 Date: 11/3/2022 https://rubyonrails.org/2022/3/11/Rails-5-2-7-has-been-released Version 5.2.7.1 Date: 26/4/2022 https://rubyonrails.org/2022/4/26/Rails-7-0-2-4-6-1-5-1-6-0-4-8-and-5-2-7-1-have-been-released Version 5.2.8 Date: 9/5/2022 https://rubyonrails.org/2022/5/9/Rails-7-0-3-6-1-6-6-0-5-and-5-2-8-have-been-released Version 5.2.8.1 Date: 12/7/2022 https://rubyonrails.org/2022/7/12/Rails-Versions-7-0-3-1-6-1-6-1-6-0-5-1-and-5-2-8-1-have-been-released We will be jumping through a lot of releases made by Rails. And the last one is the latest release they made for the 5 major version. One of the most important aspects of upgrading gems is to make sure that we are up to date with all the security patches. Not allowing any known breaches enter our application. ### Step 2: **Upgrade Ruby from 2.5.9 to 2.6.10** 2.6.10 is the latest release before the 2.7 version. Version 2.6.10 Date: 12/04/2022 https://www.ruby-lang.org/en/news/2022/04/12/ruby-2-6-10-released/ **Upgrade Rails 5.2.8.1 from to 6.0.5.1** 6.0.5.1 is the latest release before the 6.1 minor version change. Version 6.0.5.1 Date: 12/7/2022 https://rubyonrails.org/2022/7/12/Rails-Versions-7-0-3-1-6-1-6-1-6-0-5-1-and-5-2-8-1-have-been-released ### Step 3: **Upgrade Rails 6.0.5.1 from to 6.1.6.1** 6.1.61 is the latest release before the 6.2 minor version change. Version 6.1.6.1 Date: 12/07/2022 https://rubyonrails.org/2022/7/12/Rails-Versions-7-0-3-1-6-1-6-1-6-0-5-1-and-5-2-8-1-have-been-released As I did in the example before we need to research all release Notes to make sure we are following their standards. ### Step 4 **Upgrade Ruby from 2.6.10 to 2.7.6** 2.7.6 is the latest release before the 3 version. Version 2.7.6 Date: 12/04/2022 https://www.ruby-lang.org/en/news/2022/04/12/ruby-2-7-6-released/ Rails 7 NEEDS ruby to be at least 2.7. **Upgrade Rails from 6.1.6.1 to 7.0.3.1** 7.0.3.1 is the latest release Version 7.0.3.1 Date: 12/07/2022 https://rubyonrails.org/2022/7/12/Rails-Versions-7-0-3-1-6-1-6-1-6-0-5-1-and-5-2-8-1-have-been-released ### Step 5 After we reach the latest Rails version we can think about going to Ruby 3 to have a step by itself since we have some breaking changes. ## Second Option: Faster ### Step 1 **Upgrade Rails from 5.1.6 to 6.1.6.1** OR **Upgrade Ruby from 2.5.8 to 2.7.6** OR Both at the same time. ### Step 2 **Upgrade Ruby from 2.7.6 to 3.1.2** ### Step 3 **Upgrade Rails from 6.1.6.1 to 7.0.3.1** Keep in mind that Rails might release new patches in the meantime, in that case we just follow the same idea. Update to the latest possible version before a major ou manor version change. We will wait, at least, **two weeks** between each step with the code in Production. This will allow us to monitor the progress, review the process - to make new inteliggent choices in the future - and gain confidence. If we have any bugs or obstacles between the steps, we will have time to work on them little by little instead of all at once. It will also facilitate debugging since we will be delimitating the new code added. As we demonstrated in the first step of the first suggestion: We need to research all the release notes from the versions we are jumping through to make sure we are following their guidelines. And also update the bundle audit ignore and README files. The SRE team is open to negotiate the details of each step in both suggestions. But spliting this work is very necessary to reduce the impact of the changes.