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

Upgrade Rails 101: The Roadmap to Smooth Upgrades (Southeast Ruby '19)

Upgrade Rails 101: The Roadmap to Smooth Upgrades (Southeast Ruby '19)

I presented this workshop on August 1st, 2019 at Southeast Ruby.

It details a series of exercises for crafting a Rails Upgrade roadmap.

The main goal of the workshop is to explain what our process looks like at fastruby.io and how you can apply to a sample Rails application.

Thanks to the conference organizers, sponsors, and attendees! :)

Ernesto Tagwerker

August 01, 2019
Tweet

More Decks by Ernesto Tagwerker

Other Decks in Programming

Transcript

  1. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Upgrade Rails 101
    The Roadmap to
    Smooth Upgrades
    Southeast Ruby 2019

    View full-size slide

  2. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Ernesto Tagwerker
    (he/him)

    View full-size slide

  3. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Founder &
    Software Engineer
    at Ombu Labs

    View full-size slide

  4. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Founder &
    Software Engineer
    at FastRuby.io

    View full-size slide

  5. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Who is this
    workshop for?
    5

    View full-size slide

  6. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    bundle update rails ?

    View full-size slide

  7. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Workshop
    Outline
    7

    View full-size slide

  8. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Goal #1:
    The Rails
    Upgrade Roadmap
    8

    View full-size slide

  9. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Goal #2:
    The Rails
    Upgrade Process
    9

    View full-size slide

  10. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    fastruby.io/
    upgrade
    10

    View full-size slide

  11. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    #RailsUpgrades
    11

    View full-size slide

  12. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Questions are
    welcome

    View full-size slide

  13. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Pre-Requisites

    View full-size slide

  14. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    ✓ docker
    ✓ docker-compose
    ✓ git

    View full-size slide

  15. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    15
    $ git clone \
    [email protected]:fastruby/e-petitions.git
    $ cd e-petitions
    $ git fetch origin docker:docker
    $ git checkout docker

    View full-size slide

  16. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    16
    $ docker-compose up -d
    $ docker-compose exec app \
    ./bin/docker-setup

    View full-size slide

  17. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    17
    $ docker-compose exec app \
    rspec spec/models/admin_user_spec.rb
    ...
    Finished in 22.24 seconds
    (files took 7.65 seconds to load)
    81 examples, 0 failures

    View full-size slide

  18. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Questions?

    View full-size slide

  19. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Exercise #1:
    Check Pre-Requisites
    Time: 15 minutes
    https://fastruby.io/upgrade#1
    https://fastruby.io/upgrade#2
    https://fastruby.io/upgrade#3

    View full-size slide

  20. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Is our app
    ready
    for an upgrade?

    View full-size slide

  21. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    “Upgrading
    Rails is easy.” —
    No one.
    21

    View full-size slide

  22. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    - “Upgrading
    Rails is easy,
    right?”
    - “Right, right,
    easy…”

    View full-size slide

  23. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Does our
    test suite
    succeed?
    23

    View full-size slide

  24. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Does our app
    have decent
    test coverage?
    24

    View full-size slide

  25. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Exercise #2:
    Calculate Test
    Coverage

    View full-size slide

  26. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    SimpleCov
    26

    View full-size slide

  27. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    27
    # Gemfile
    group :test do
    gem 'simplecov', require: false
    end

    View full-size slide

  28. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    28
    # spec/spec_helper.rb
    if ENV['COVERAGE'] == 'true'
    require 'simplecov'
    SimpleCov.start 'rails'
    end

    View full-size slide

  29. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    29
    $ docker-compose run
    -e COVERAGE=true app
    rspec spec/models/

    View full-size slide

  30. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Questions?

    View full-size slide

  31. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    31
    Exercise #2:
    Check Test Coverage
    Time: 15 minutes
    https://fastruby.io/upgrade#4

    View full-size slide

  32. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Is upgrading a
    good idea?

    View full-size slide

  33. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade

    View full-size slide

  34. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Upgrading is
    always
    a good idea
    34

    View full-size slide

  35. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dependencies
    Checkup

    View full-size slide

  36. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    SemVer
    36

    View full-size slide

  37. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    ..
    37

    View full-size slide

  38. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade

    View full-size slide

  39. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Rails 5.0.7
    MAJOR: 5
    MINOR: 0
    PATCH: 7
    39

    View full-size slide

  40. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Fixed
    vs.
    Pessimistic
    40

    View full-size slide

  41. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    41
    # Gemfile (fixed version)
    source 'https://rubygems.org'
    gem 'rails', '4.2.7'

    View full-size slide

  42. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    42
    $ bundle update
    $ cat Gemfile.lock | grep rails
    rails (4.2.7)

    View full-size slide

  43. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    43
    # Gemfile (pessimistic versions)
    source 'https://rubygems.org'
    gem 'rails', '~> 4.2.7'

    View full-size slide

  44. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    44
    $ bundle update
    $ cat Gemfile.lock | grep rails
    rails (4.2.11.1)

    View full-size slide

  45. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dependencies
    should be
    pessimistic*
    45

    View full-size slide

  46. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Exercise #3:
    Relax our Gemfile

    View full-size slide

  47. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Let’s analyze
    our Gemfile
    47

    View full-size slide

  48. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    48
    $ docker-compose exec app bundle
    outdated
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies.....
    Outdated gems included in the bundle:
    * actionmailer (newest 5.2.3, installed 4.2.11.1)
    * actionpack (newest 5.2.3, installed 4.2.11.1)
    * actionview (newest 5.2.3, installed 4.2.11.1)
    * activejob (newest 5.2.3, installed 4.2.11.1)
    * activemodel (newest 5.2.3, installed 4.2.11.1)
    * activerecord (newest 5.2.3, installed 4.2.11.1)
    * activesupport (newest 5.2.3, installed 4.2.11.1)
    ...

    View full-size slide

  49. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    49
    # Gemfile
    group :development do
    gem 'next_rails'
    end

    View full-size slide

  50. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    $ docker-compose down
    $ docker-compose up --build -d

    View full-size slide

  51. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    $ docker-compose exec app \
    bundle_report outdated
    ...
    aws-sdk 2.11.314: released 19 days ago
    (latest version, 3.0.1, released almost 2
    years ago)
    0 gems are sourced from git
    44 of the 139 gems are out-of-date (32%)

    View full-size slide

  52. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    For every fixed
    dependency declaration:
    - Turn it into a pessimistic
    declaration
    52

    View full-size slide

  53. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    For every fixed dependency
    declaration we change:
    53
    $ docker-compose down --volumes
    $ docker-compose up --build -d

    View full-size slide

  54. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    For every fixed
    dependency declaration we
    change:
    54
    $ docker-compose exec app \
    rspec spec/lib/atomic_dalli_store_spec.rb

    View full-size slide

  55. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Does your build pass?
    - Submit a PR
    - Create a story
    55

    View full-size slide

  56. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Questions?

    View full-size slide

  57. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    57
    Exercise #3:
    Pessimistic Dependencies
    Time: 10 minutes
    https://fastruby.io/upgrade#5
    https://fastruby.io/upgrade#6

    View full-size slide

  58. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    What
    happened?
    58

    View full-size slide

  59. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dual Boot:
    Setup

    View full-size slide

  60. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Let’s bump that
    Rails version
    60

    View full-size slide

  61. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    ONE DOES NOT SIMPLY
    BUNDLE UPDATE RAILS

    View full-size slide

  62. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dual Boot:
    There are many gems for that
    62

    View full-size slide

  63. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    63
    # Gemfile
    group :development do
    gem 'next_rails'
    end

    View full-size slide

  64. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    64
    $ docker-compose exec app next --init
    Created Gemfile.next (a symlink to your Gemfile). Your Gemfile
    has been modified to support dual-booting!
    There's just one more step: modify your Gemfile to use a newer
    version of Rails using the `next?` helper method.
    For example, here's how to go from 5.2.3 to 6.0:
    if next?
    gem "rails", "6.0.0"
    else
    gem "rails", "5.2.3"
    end

    View full-size slide

  65. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    65
    # Gemfile
    def next?
    File.basename(__FILE__) ==
    "Gemfile.next"
    end
    source ‘https://rubygems.org'
    gem 'rails', '4.2.11.1'

    View full-size slide

  66. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    66
    # Gemfile
    if next?
    gem 'rails', '~> 5.0.7'
    else
    gem 'rails', '4.2.11.1'
    end

    View full-size slide

  67. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    67
    $ docker-compose exec \
    next bundle install
    $ cat Gemfile.next.lock

    View full-size slide

  68. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    68
    # Dockerfile
    COPY Gemfile Gemfile.lock ./
    COPY Gemfile.next Gemfile.next.lock ./
    RUN gem install bundler -v=1.17.3
    RUN bundle install
    RUN next bundle install
    COPY . .

    View full-size slide

  69. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    69
    $ docker-compose down
    $ docker-compose up --build -d
    $ docker-compose exec app \
    ./bin/docker-setup

    View full-size slide

  70. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Incompatibilities
    70

    View full-size slide

  71. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    71
    $ docker-compose exec app \
    bundle_report compatibility --rails-version=5.0.7
    => Incompatible with Rails 5.0.7 (with new versions that are
    compatible):
    These gems will need to be upgraded before upgrading to Rails
    5.0.7.
    rails-dom-testing 1.0.9 - upgrade to 2.0.3
    test_after_commit 1.2.2 - new version, 1.2.2, is not compatible
    with Rails 5.0.7
    2 gems incompatible with Rails 5.0.7

    View full-size slide

  72. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    72
    Exercise #4:
    next bundle install
    Time: 15 minutes
    https://fastruby.io/upgrade#7

    View full-size slide

  73. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    #CoffeeBreak

    View full-size slide

  74. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dual Boot:
    Test Models

    View full-size slide

  75. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Now that you can
    next bundle install
    successfully...
    75

    View full-size slide

  76. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    76
    $ docker-compose exec app \
    next rspec spec/models

    View full-size slide

  77. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Failures
    77

    View full-size slide

  78. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    78
    $ docker-compose exec app \
    next rspec spec/models
    rake aborted!
    Bundler::GemRequireError: There was an error while trying to load
    the gem 'test_after_commit'.
    Gem Load Error is: after_commit testing is baked into rails 5, you
    no longer need test_after_commit gem
    Backtrace for gem load error is:
    /Users/etagwerker/.rvm/gems/ruby-2.4.5@petitions/gems/
    test_after_commit-1.1.0/lib/test_after_commit.rb:4:in `(required)>'
    /Users/etagwerker/.rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/
    bundler/runtime.rb:81:in `require'
    /Users/etagwerker/.rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/
    bundler/runtime.rb:81:in `block (2 levels) in require'
    /Users/etagwerker/.rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/
    bundler/runtime.rb:76:in `each'

    View full-size slide

  79. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    79
    # Gemfile
    group :test do
    # ...
    gem 'test_after_commit' unless next?
    end

    View full-size slide

  80. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    # spec/support/after_commits.rb
    if defined?(TestAfterCommit)
    TestAfterCommit.enabled = false
    RSpec.configure do |config|
    config.around(:each) do |example|
    # ...
    end
    end
    end

    View full-size slide

  81. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    81
    $ docker-compose exec app \
    next rspec spec/models
    NoMethodError:
    undefined method `hide_action' for
    Delayed::Web::ApplicationController:Class
    # ./config/initializers/delayed_web.rb:10:in `block in (required)>'
    # ./config/initializers/delayed_web.rb:7:in `class_eval'
    # ./config/initializers/delayed_web.rb:7:in `'
    # /Users/etagwerker/.rvm/gems/ruby-2.4.5@petitions/gems/
    activesupport-5.0.7.2/lib/active_support/dependencies.rb:287:in
    `load'
    # /Users/etagwerker/.rvm/gems/ruby-2.4.5@petitions/gems/
    activesupport-5.0.7.2/lib/active_support/dependencies.rb:287:in
    `block in load'
    # /Users/etagwerker/.rvm/gems/ruby-2.4.5@petitions/gems/
    activesupport-5.0.7.2/lib/active_support/dependencies.rb:259:in
    `load_dependency'

    View full-size slide

  82. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    82
    # config/initializers/delayed_web.rb
    Delayed::Web::ApplicationController.class_eval do
    include Authentication, FlashI18n
    hide_action :admin_request?
    def admin_request?
    true
    end
    protected
    def admin_login_url
    main_app.admin_login_url
    end
    end

    View full-size slide

  83. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    83
    # config/initializers/delayed_web.rb
    Delayed::Web::ApplicationController.class_eval do
    include Authentication, FlashI18n
    protected
    def admin_request?
    true
    end
    def admin_login_url
    main_app.admin_login_url
    end
    end

    View full-size slide

  84. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Fix Failures
    84

    View full-size slide

  85. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Deprecation
    Warnings
    85

    View full-size slide

  86. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    86
    $ docker-compose exec app \
    next rspec spec/models
    DEPRECATION WARNING:
    ActiveRecord::Base.raise_in_transactional_callbacks= is
    deprecated, has no effect and will be removed without
    replacement. (called from at /usr/src/app/
    config/environment.rb:5)
    DEPRECATION WARNING: #table_exists? currently checks both
    tables and views. This behavior is deprecated and will be
    changed with Rails 5.1 to only check tables. Use
    #data_source_exists? instead. (called from table_exists? at /
    usr/src/app/app/models/site.rb:23)
    DEPRECATION WARNING: Passing an argument to force an
    association to reload is now deprecated and will be removed
    in Rails 5.1. Please call `reload_rejection` instead. (called
    from rejection at /usr/src/app/app/models/petition.rb:639)
    ...

    View full-size slide

  87. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    One Item per
    Deprecation
    Warning
    87

    View full-size slide

  88. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    88
    Exercise #5:
    next rspec spec/models
    Time: 20 minutes
    https://fastruby.io/upgrade#8

    View full-size slide

  89. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    What
    happened?
    89

    View full-size slide

  90. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dual Boot:
    Test Libraries

    View full-size slide

  91. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    91
    $ docker-compose exec app \
    next rspec spec/lib
    DEPRECATION WARNING: `config.serve_static_files` is deprecated and will be
    removed in Rails 5.1.
    Please use `config.public_file_server.enabled = true` instead.
    (called from block in at /usr/src/app/config/environments/
    test.rb:16)
    DEPRECATION WARNING: `config.static_cache_control` is deprecated and will be
    removed in Rails 5.1.
    Please use
    `config.public_file_server.headers = { 'Cache-Control' => 'public, max-
    age=3600' }`
    instead.
    (called from block in at /usr/src/app/config/environments/
    test.rb:17)

    View full-size slide

  92. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    92
    Exercise #6:
    next rspec spec/lib
    Time: 10 minutes
    https://fastruby.io/upgrade#9

    View full-size slide

  93. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    What
    happened?
    93

    View full-size slide

  94. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Dual Boot:
    Test Controllers

    View full-size slide

  95. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    95
    $ docker-compose exec app \
    next rspec spec/controllers
    DEPRECATION WARNING: Using positional arguments in functional tests has been
    deprecated,
    in favor of keyword arguments, and will be removed in Rails 5.1.
    Deprecated style:
    get :show, { id: 1 }, nil, { notice: "This is a flash message" }
    New keyword style:
    get :show, params: { id: 1 }, flash: { notice: "This is a flash message" },
    session: nil # Can safely be omitted.
    (called from block (4 levels) in at /usr/src/app/spec/
    controllers/admin/petition_tags_controller_spec.rb:46)
    DEPRECATION WARNING: Using positional arguments in functional tests has been
    deprecated,
    in favor of keyword arguments, and will be removed in Rails 5.1.

    View full-size slide

  96. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    # Gemfile
    group :development, :test do
    gem 'next_rails', '~> 1.0.1'
    # …
    gem 'rubocop'
    gem 'rubocop-rails'
    end

    View full-size slide

  97. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    97
    $ docker-compose down
    $ docker-compose up --build -d
    $ docker-compose exec app \
    ./bin/docker-setup

    View full-size slide

  98. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    98
    $ docker-compose exec app \
    rubocop \
    --only Rails/HttpPositionalArguments \
    --require rubocop-rails
    --auto-correct
    spec/controllers

    View full-size slide

  99. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    99
    $ docker-compose exec app \
    next rspec spec/controllers

    View full-size slide

  100. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    100
    Exercise #7:
    next rspec
    spec/controllers
    Time: 15 minutes
    https://fastruby.io/upgrade#10

    View full-size slide

  101. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Find References
    To Deprecated
    API

    View full-size slide

  102. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    https://edgeguides.rubyonrails.org/
    upgrading_ruby_on_rails.html
    Official Guides

    View full-size slide

  103. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Unofficial Guides
    103
    1.https://fastruby.io/blog/rails/upgrades/upgrade-to-rails-3.html
    2.https://fastruby.io/blog/rails/upgrades/upgrade-to-rails-3-1.html
    3.https://fastruby.io/blog/rails/upgrades/upgrade-to-rails-3-2.html
    4.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-3-2-to-4-0.html
    5.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-4-0-to-4-1.html
    6.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-4-1-to-4-2.html
    7.https://fastruby.io/blog/rails/upgrades/active-record-5-1-api-changes.html
    8.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-4-2-to-5-0.html
    9.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-5-0-to-5-1.html
    10.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-5-1-to-5-2.html
    11.https://fastruby.io/blog/rails/upgrades/upgrade-rails-from-5-2-to-6-0.html

    View full-size slide

  104. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    http://railsdiff.org/
    RailsDiff

    View full-size slide

  105. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Find In
    Project
    105

    View full-size slide

  106. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Trust
    The Process

    View full-size slide

  107. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Gradual
    version
    jumps
    107

    View full-size slide

  108. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    ...
    ✅ 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
    108
    Gemfile Gemfile.next
    { }

    View full-size slide

  109. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    For every version jump:
    bundle install
    bundle exec rake
    Smoke test
    109

    View full-size slide

  110. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Ship
    backwards-compatible
    changes first
    110

    View full-size slide

  111. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Every
    deprecation
    warning is a story
    111

    View full-size slide

  112. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Every
    failing scenario
    is a story
    112

    View full-size slide

  113. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Tiny Pull Requests
    over
    One Huge PR
    113

    View full-size slide

  114. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Tiny Changesets
    over
    Huge Changesets
    114

    View full-size slide

  115. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    1. Tweak
    2. Test
    3. Merge
    And
    Iterate

    View full-size slide

  116. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    The Version Jump
    Pull Request
    is Last
    116

    View full-size slide

  117. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    How To
    Stay Current

    View full-size slide

  118. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Treat new
    deprecation warnings
    as exceptions
    118

    View full-size slide

  119. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    # config/environments/test.rb
    Rails.application.configure do
    # ...
    # Raise on deprecation notices
    config.active_support.deprecation = :raise
    # ...
    end
    119

    View full-size slide

  120. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Add bundler-audit
    to your default
    rake task
    120

    View full-size slide

  121. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    # Rakefile
    # ...
    task default: %i[
    bundle:audit brakeman:check
    spec spec:javascripts cucumber
    ]
    121

    View full-size slide

  122. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    namespace :bundle do
    desc "Audit bundle for any known vulnerabilities"
    task :audit do
    unless system "bundle-audit check --update"
    exit 1
    end
    end
    end
    122

    View full-size slide

  123. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Keep up with
    upcoming releases
    123

    View full-size slide

  124. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    124
    # Gemfile
    source 'https://rubygems.org'
    git_source(:github) do |repo_name|
    repo_name = "#{repo_name}/#{repo_name}" unless
    repo_name.include?("/")
    "https://github.com/#{repo_name}.git"
    end
    if next?
    gem 'rails', github: 'rails/rails'
    else
    gem 'rails', '~> 6.0.0.rc2'
    end

    View full-size slide

  125. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    @etagwerker
    #RailsUpgrades
    fastruby.io
    Feedback is welcome

    View full-size slide

  126. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    126
    Thank You!

    View full-size slide

  127. @etagwerker | #RailsUpgrades | https://fastruby.io/upgrade
    Resources
    127
    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

    View full-size slide