> [!METADATA]+ > **Type**:: [[Conference Talk]] > **Conference**:: [[Sin City Ruby 2022]] > **Authors**:: [[@Andrea Fomera]] > **Links**:: --- ## ✏️ Notes - Upgrading rails - doesnt have to be scary - intro into how you can do it - Covering - Three approaches to upgrade - Dual booting - Takeaways - no specifics - 7 Rails upgrades - Speaker - [[@Andrea Fomera]] - she/her - Product dev at podia - afomera.dev - PODIA - Eiffel tower - Why should you upgrade - Possible perf improvements - More attractive to developers - Fuck Rails 3 - Easier to find helpful docs - Security updates, bug fixes - Security patches only go so far back - New framework features - things to consider - Team **buy in** (buy-in?) - Good test suite - <https://remoteruby.com/100> - Persistence - 3 Things to Consider <- 3 Other things? - Is ruby up to date/compatible? - bootboot - Include link to bootboot? - Gems that are out of date - Extending core Rails functionality - Context is key - Gems out of date? - blocker to get app bundling and booting - Depfu AT PODIA - Dependabot - Ship changelogs! - <https://andrewm.codes/blog/automating-ruby-gem-releases-with-github-actions/> - GitHub now has automated changelogs - 3 Ways to Upgrade - Paying someone else - <https://www.fastruby.io> - Require high level of test coverage or QA team - Again: <https://remoteruby.com/100> - Long-running branch - SHIP IT - Dual-Booting - [[github]] && [[Shopify]] - Current version and next version of Rails - Each strategy - Scan logs and fix deprecation messages & REPEAT - Update your gemfile to update Rails (capitalize Gemfile?) - Rails upgrade guides - RAILSDIFF <https://railsdiff.org/> - `rails app:update` - TEST YOUR ROLLBACK PLAN - Sessions and Cookies? - All users logged out? - How to dual-boot - `next-rails` - `bootboot` - [[Shopify]] [[Bundler]] plugin ```ruby # Gemfile le plugin ' bootboot', 'N> 0.2' # In your terminal... run bundle bootboot # It will add the following to your gemfile. Plugin. send( : load_plugin, 'bootboot') if Plugin. installed?('bootboot') if ENV[ 'DEPENDENCIES_NEXT' ] enable_dual_booting if Plugin.installed?('bootboot') # Add any gem you want here, they will be loaded only when running # bundler command prefixed with 'DEPENDENCIES NEXT=1 end ``` ```ruby if ENV[ "DEPENDENCIES_NEXT" ] enable_dual_booting if Plugin. installed?("bootboot") gem "rails", github: "rails/rails", branch: "main" else gem "rails", "~> 6.1.4" end ``` ```ruby # Install gems for the next version DEPENDENCIES_NEXT=1 bundle install # Load a Rails console DEPENDENCIES NEXT=1 rails console # Start server DEPENDENCIES_NEXT=1 rails server ``` - You can run it in staging/production! - tricky with [[Heroku]] pipelines - Set up a separate CI build - Make sure to use `DEPENDENCIES_NEXT=1` - Podia uses separate [[GitHub Actions]] ```ruby if ENV["DEPENDENCIES_NEXT" ] # code that only works in the new version else # code that works in old version only end # code that works in both versions ``` - Pros of dual-booting - Smaller, easier to review PRs (comma!) - Easier test a rollout, rollback strategy - Log in to app using old version or rails, stop and run app in new version - Stop and go back to older versios - Signed-IDs? Sessions? Cookies? - Reduces risk of falling behind and abandoning attempts - Cons - Cleanup the `if` statements - [[rubocop]] linter to take care of this for you - Ship code that doesn't need an if statement - Prefix commands with `DEPENDENCIES_NEXT` - Prefix can be changed - `RAILS_NEXT` - May not be applicable if application is small - May be overkill? - Key takeaways - Try upgrade non-rails dependencies - Take it slow - Read the docs - TEST ROLLBACK PLANS