Skip to content

Upgrading to Rails 6

bencomp edited this page Aug 4, 2020 · 2 revisions

Although we deploy using automated Capistrano scripts, the installation process is the same whether you have it automated or run each step manually. If any of these details don't match your process, please let us know and we'd be happy to discuss the differences with you.

Prepare for the upgrade:

  1. Install Ruby 2.7.1. Hopefully you're using rvm; if so a: rvm install 2.7.1 will take care of it.

  2. Install nodejs and yarn. Yarn is the JavaScript package manager used by Rails 6 and it depends on NodeJS. You'll find the instructions for your platform here: https://github.com/nodesource/distributions/blob/master/README.md (Please follow these instructions to ensure you get the right version of node as some distributions' package managers only have older versions available.)

  3. Create a new Apache config (I have a fromthepage.conf in sites-enabled) that points PassengerRuby to the new ruby. With RVM on our servers this was /home/fromthepage/.rvm/wrappers/ruby-2.7.1@global/ruby. I created this before the actual upgrade and swapped them out as soon as the upgrade was done to minimize downtime.

Do the upgrade:

  1. Pull down the new code. (The Rails 6 release contains new code but also deleted code. Our Capistrano scripts do not update software in place, but rather pull code into a brand new directory, then symlink the shared directories that contain configuration and state. Those linked files and directories are specified in https://github.com/benwbrum/fromthepage/blob/master/config/deploy.rb#L25-L30 )

  2. Install all the required dependencies: cd /home/fromthepage/deployment/releases/20200728020150 && /home/fromthepage/deployment/rvm1scripts/rvm-auto.sh . bundle install --path /home/fromthepage/deployment/shared/bundle --without development test --deployment --quiet (You might be able to simply do an rvm use 2.7.1; bundle install --path /home/fromthepage/deployment/shared/bundle --without development test --deployment if you are not using Capistrano.) On our staging and production servers this took just over 5 minutes to run.

  3. Precompile the assets: cd /home/fromthepage/deployment/releases/20200728020150 && ( export RAILS_ENV="production" ; /home/fromthepage/deployment/rvm1scripts/rvm-auto.sh . bundle exec rake assets:precompile )

  4. Migrate the database: export RAILS_ENV="production" ; /home/fromthepage/deployment/rvm1scripts/rvm-auto.sh . bundle exec rake db:migrate On our servers this took about 15 minutes to complete, but your smaller database should go much faster.

  5. Swap out the apache config you created in step 3 (or just edit it to point to ruby 2.7.1).

  6. Restart apache.

  7. Do some manual testing -- log in, transcribe a page.