The Rails db:system:change command

April 3, 2019

Track your progress

Sign in to track your progress and access subscription-only lessons.

Log In

Your Teacher

Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.

About This Episode

Changing the database adapter for a Rails app has always been an annoying, manual change to make. Rails 6.0 introduces the "rails db:system:change" command to make this easier using all the built-in generators for database.yml and more.

Notes

To use the Rails 6 db system change command, you simply need to specify the new database adapter with the --to option.

rails db:system:change --to=postgresql
rails db:system:change --to=mysql
rails db:system:change --to=sqlite3
rails db:system:change --to=oracle
rails db:system:change --to=frontbase
rails db:system:change --to=sqlserver
rails db:system:change --to=jdbc

Keep in mind, you may need to change the version numbers of the database adapter in your Gemfile after running this command.

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.