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

Upgrading Rails: The Dual-Boot Way

Upgrading Rails: The Dual-Boot Way

Upgrading Rails is easy, right? Sure, as long as you are upgrading your patch version. A Rails upgrade project for a majestic monolith is not a trivial project. While upgrades have become easier with every new Rails version, your application has only become more complicated with every new dependency.

In this workshop you will learn a proven Rails upgrade process which relies on "dual booting" to quickly iterate and upgrade! You will leave this workshop with a new set of tools that will make your next upgrade project less daunting.

Avatar for Ernesto Tagwerker

Ernesto Tagwerker

April 12, 2021
Tweet

More Decks by Ernesto Tagwerker

Other Decks in Programming

Transcript

  1. #RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails

    - Dual Boot Setup - next bundle install - next bundle exec rails console 22
  2. #RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails

    - Dual Boot Setup - next bundle install - next bundle exec rails console - next bundle exec rake test 23
  3. #RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails

    - Dual Boot Setup - next bundle install - next bundle exec rails console - next bundle exec rake test - next bundle exec rails server 24
  4. #RailsUpgrades | https://fastruby.io/rc2021 Using your own app: ✓ ruby 2.3.8

    or above ✓ bundle install ✓ bundle exec rake test *
  5. #RailsUpgrades| https://fastruby.io/rc2021 33 $ rspec spec DEPRECATION WARNING: The factory_girl

    gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/ v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/lib/ruby/site_ruby/2.5.0/bundler/ runtime.rb:81) ..................................... Finished in 1.82 seconds (files took 4.7 seconds to load) 37 examples, 0 failures
  6. #RailsUpgrades| https://fastruby.io/rc2021 Exercise #1: Check Pre-Requisites Time: 5 to 10

    minutes https://fastruby.io/rc2021#1 https://fastruby.io/rc2021#2
  7. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle Fetching gem metadata from https://rubygems.org/.......... ...

    Fetching next_rails 1.0.3 Installing next_rails 1.0.3 ... Bundle complete! 30 Gemfile dependencies, 106 gems now installed.
  8. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5

    years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)
  9. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5

    years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)
  10. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5

    years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)
  11. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5

    years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)
  12. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report compatibility --rails-version=5.0.0 => Incompatible with Rails

    5.0.0 (with new versions that are compatible): These gems will need to be upgraded before upgrading to Rails 5.0.0. rails-dom-testing 1.0.9 - upgrade to 2.0.3 sass-rails 4.0.5 - upgrade to 6.0.0 => Incompatible with Rails 5.0.0 (with no new compatible versions): These gems will need to be removed or replaced before upgrading to Rails 5.0.0. coffee-rails 4.0.1 - new version, 5.0.0, is not compatible with Rails 5.0.0 3 gems incompatible with Rails 5.0.0
  13. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report compatibility --rails-version=5.0.0 => Incompatible with Rails

    5.0.0 (with new versions that are compatible): These gems will need to be upgraded before upgrading to Rails 5.0.0. rails-dom-testing 1.0.9 - upgrade to 2.0.3 sass-rails 4.0.5 - upgrade to 6.0.0 => Incompatible with Rails 5.0.0 (with no new compatible versions): These gems will need to be removed or replaced before upgrading to Rails 5.0.0. coffee-rails 4.0.1 - new version, 5.0.0, is not compatible with Rails 5.0.0 3 gems incompatible with Rails 5.0.0
  14. #RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report compatibility --rails-version=5.0.0 => Incompatible with Rails

    5.0.0 (with new versions that are compatible): These gems will need to be upgraded before upgrading to Rails 5.0.0. rails-dom-testing 1.0.9 - upgrade to 2.0.3 sass-rails 4.0.5 - upgrade to 6.0.0 => Incompatible with Rails 5.0.0 (with no new compatible versions): These gems will need to be removed or replaced before upgrading to Rails 5.0.0. coffee-rails 4.0.1 - new version, 5.0.0, is not compatible with Rails 5.0.0 3 gems incompatible with Rails 5.0.0
  15. #RailsUpgrades| https://www.fastruby.io/rc2021 Exercise #2: (Time: 7 minutes) 1) Install next_rails

    gem 2) Run bundle_report outdated 3) Run bundle_report compatibility --rails-version=x.x.x https://www.fastruby.io/rc2021#3
  16. #RailsUpgrades| https://www.fastruby.io/rc2021 Exercise #3: (Time: 5 minutes) 1) Run next

    --init 2) Check that a Gemfile.next was created 3) Check that you have the next? method in your Gemfile https://www.fastruby.io/rc2021#4
  17. #RailsUpgrades| https://www.fastruby.io/rc2021 $ next bundle install ... Bundler could not

    find compatible versions for gem "actionpack": In snapshot (Gemfile.next.lock): actionpack (= 4.2.11.3) In Gemfile.next: rails (~> 5.0.0) was resolved to 5.0.1.rc1, which depends on actionpack (= 5.0.1.rc1) sass-rails (~> 4.0.3) was resolved to 4.0.5, which depends on railties (>= 4.0.0, < 5.0) was resolved to 4.2.11.3, which depends on actionpack (= 4.2.11.3) Running `bundle update` will rebuild your snapshot from scratch, using only the gems in your Gemfile, which may resolve the conflict.
  18. #RailsUpgrades| https://fastruby.io/rc2021 73 $ bundle exec rails console irb(main):001:0> Rails.version

    => "4.2.11.3" irb(main):002:0> $ next bundle exec rails console irb(main):001:0> Rails.version => "5.0.7.2" irb(main):002:0>
  19. #RailsUpgrades| https://fastruby.io/rc2021 namespace :bundle do desc "Audit bundle for any

    known vulnerabilities" task :audit do unless system "bundle-audit check --update" exit 1 end end end 87
  20. #RailsUpgrades| https://fastruby.io/rc2021 ... ✅ 2.3 👉 3.0 ✅ 3.0 👉

    3.1 ✅ 3.1 👉 3.2 ✅ 3.2 👉 4.0 ✅ 4.0 👉 4.1 ✅ 4.1 👉 4.2 ✅ 4.2 👉 5.0 ✅ 5.0 👉 5.1 ✅ 5.1 👉 5.2 ✅ 5.2 👉 6.0 ✅ 6.0 👉 6.1 ✅ 6.1 👉 7.0 93 Gemfile Gemfile.next { }
  21. #RailsUpgrades| https://fastruby.io/rc2021 Results - Your app running on the next

    version of Rails - A roadmap to upgrade your app 99
  22. #RailsUpgrades| https://fastruby.io/rc2021 Results - Your app running on the next

    version of Rails - A roadmap to upgrade your app - A new tool for your toolbelt 100
  23. #RailsUpgrades| https://fastruby.io/rc2021 Resources 1.https://github.com/clio/ten_years_rails 2.https://github.com/alphagov/e-petitions 3.https://github.com/rubyperu/ready4rails 4.https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#the-upgrade-process 5.https://fastruby.io/blog/tags/upgrades 6.https://semver.org 7.https://github.com/Shopify/bootboot

    8.https://github.com/fastruby/rails_upgrader 9.http://railsdiff.org 10.https://github.com/hintmedia/moderate_parameters 11.https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#the-update-task 12.https://www.fastruby.io/blog/rails/upgrade/dual-booting-with-conditionals.html 13.https://www.fastruby.io/blog/upgrade-rails/dual-boot/dual-boot-with-rails-6-0-beta.html 14.http://recursion.org/incremental-rails-upgrade