Suggestions re upgrading an old app

Hi there, I had an attempt to do this a while back, but left an app at 4.2.8 for the time being. So I thought I would try again getting it up to 7.1 The app is fairly simple (most crud with some basic logic). If I create a new 7.1 app and point it to the database on Heroku, what is the best way to get the schema up to date, so that future db changes can be done ? TIA, Dave

When you point a new application to an existing database then run rails db:migrate it will populate the db/schema.rb with any syntax change.

Thanks Thomas, So do you mean I copy over all the files from the migrate folder from the current version ? Dave

The migration files are here to change the database schema but you already have a database up and running. So no need to copy over the migration file. Also, if you start a database from zero, I would recommend you to use rails db:schema:load that will use the db/schema.rb to create tables and columns.

Hello Dave,

Can you provide a little more context we might be able to help you more. Have you tried updating the current app? I would suggest doing an incremental upgrade until you get to the latest Rails you want.

1 Like

Thanks for all the help. So I tried going from my current 4.2 version to 5.0.7.2 When I enter Bundle update I get lots of failure messages such as:

Bundler could not find compatible versions for gem “actionpack”: In Gemfile: rails (= 5.0.7.2) was resolved to 5.0.7.2, which depends on actionpack (= 5.0.7.2)

simple_form (~> 5.0, >= 5.0.2) was resolved to 5.0.3, which depends on
  actionpack (>= 5.0)

Bundler could not find compatible versions for gem “activemodel”: In Gemfile: rails (= 5.0.7.2) was resolved to 5.0.7.2, which depends on activemodel (= 5.0.7.2)

web-console was resolved to 1.0.1, which depends on
  activemodel (~> 4.0.0)

I started to investigate what version I should configure each gem at, but found this hard to find specifically for 5.0.7.2 ? My gemfile before I started making changes other than the rails version! Appreciate further thoughts? Dave

source ‘https://rubygems.org’

Standard Rails gems

ruby ‘2.6.8’

gem ‘rails’, ‘4.2.8’

gem ‘rails’, ‘5.0.7.2’ gem ‘sass-rails’, ‘~> 5.0’ gem ‘uglifier’, ‘>= 1.3.0’ gem ‘coffee-rails’, ‘~> 4.1.0’ gem ‘jquery-rails’, “~> 2.3.0” gem ‘momentjs-rails’, ‘>= 2.9.0’ gem ‘bootstrap3-datetimepicker-rails’, ‘~> 4.14.30’ gem ‘turbolinks’ gem ‘jbuilder’, ‘~> 2.0’ gem ‘bootstrap-sass’ gem ‘devise’ gem ‘simple_form’ gem “simple_form”, “>= 3.5.1” gem ‘unicorn’ gem ‘unicorn-rails’ gem ‘bootswatch-rails’ gem ‘kaminari’ gem ‘rails_db’ gem “pundit” gem ‘rails_12factor’ gem “puma” gem ‘sqlite3’

Use sqlite3 as the database for Active Record

gem “rack”, “>= 2.1.4” gem “nokogiri” “1.12.3”

group :production do gem ‘pg’, ‘~> 0.21’ end

group :development do gem ‘sqlite3’, ‘~> 1.3.6’ gem ‘better_errors’ gem ‘quiet_assets’ gem ‘rails_layout’ end

group :development, :test do gem ‘sqlite3’ gem ‘byebug’ gem ‘web-console’, ‘~> 2.0’ gem ‘spring’ end

I managed to resolve this and the app is now updated to RoR 5 locally on my Mac. I found a discussion on github for bundler where someone had the same issue and they remarked out all the gems except rails, run bundle update which worked, then un-rem each gem one-by-one and bundle update again. A bit laborious, but it worked. Thanks for everyone’s help!

1 Like