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.
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!