Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby on Rails Upgrade

Ruby on Rails Upgrade

Amree Zaid

October 16, 2023
Tweet

More Decks by Amree Zaid

Other Decks in Programming

Transcript

  1. Appreciation 🙏 Thanks for the reviews, being backups during deployments,

    putting up with git conflicts on staging, getting flooded with messages about me asking for reviews, giving hints on how to fix the incidents, giving me the trust and time to work on this, spending money on the extra servers in production and staging, etc
  2. Context 👀 Controllers ~150 Models ~200 Routes ~1,300 (EN) Gems

    ~390 Test Coverage 83% (77%) Rails v5.2.7 (2022, v5 = 2018) Ruby v2.5.8 (2020)
  3. Approval from the Product and Management Be ready to answer

    the WHY From fastruby.io: • More time building, not fixing • Attract and retain talented developers • Use the new features • Reduced running costs
  4. Prerequisite • Sufficient (?) test coverage - 80% • Error

    tracking tools - New Relic (NR), Bugsnag • A way to split the traffic in Production • Persistence
  5. Time Estimation It’s hard. General rule: • Figure out which

    gems needs to be upgraded • ~1 week on Staging • Time gap between major deployments - 1 week minimum
  6. Which gems to start with? Hack your way through. Rely

    on rubygems.org a lot 1. git checkout am-upgrade-rails-527-hack 2. 3. # Gemfile 4. gem "rails", "5.2.7" 5. 6. bundle 7. 8. # Comment out gems that has problems 9. 10. bundle # again 11. 12. # Keep on repeating bundle and commenting
  7. Rules 󰠖 1. I can merge the gem upgrade ASAP

    to the master 2. Must read the CHANGELOG 3. Must be deployed on Staging 4. Must try re-running some of the gem features 5. Bigger gaps in terms of the time for high risk gems 6. Limit the deployments per pay 7. Schedule big upgrades 8. Big upgrade must be done on Monday morning 9. Document as much as you can 10. Get someone as a backup during deployment
  8. Notes for Upgrading to Rails v7.0.4 🗒 1. git checkout

    am-before-rails7_0_4; git reset --hard master 2. 3. git merge am-upgrade-redis-actionpack \ 4. am-upgrade-devise-token-auth \ 5. am-upgrade-primer-view-components \ 6. am-remove-sti \ 7. am-fix-activemodel-keys-deprecation \ 8. am-add-net-http \ 9. am-deprecate-api-v2 \ 10. am-update-csrf-token \ 11. am-upgrade-acts-as-taggable-on 12. 13. git checkout am-upgrade-rails7_0_4 ; git reset --soft HEAD~1; git reset; git checkout Gemfile.lock ; git add; git stash; git reset --hard am-before-rails7_0_4; git stash pop # fix conflicts 14. bundle update rails rails-i18n 15. 16. git add .; git commit -m 'Upgrade Rails from v6.1.7 to v7.0.4'
  9. Improvements • Split resources during deployment • Faster hotfix release

    • Store basic data, not object / Prefix or version the cache • Get a dedicated team members (more than 1 person) • Figure out a way to not do this again lol