Hello guys !
sometimes I came across the need to change the application's database, because many times we start with a study project with Sqlite3 and then the project ends up getting bigger with another need and then we decided to change to another one like (PostgreSQL, MySQL, etc ...)!
So here's a nice little tip:
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
**obs: only works from rails version 6 onwards
Top comments (5)
But when I run the command,
rails db:system:change --to=postgresql
it says that
Running via Spring preloader in process 15186
invalid option: --to=postgresql
my env:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
Rails 6.1.4.1
Strange here it worked, tested other databases?
Mysql is the same result.
The workaround is to disable 'spring' as follows.
gem 'spring'
in the GemfileDetails are below issue.
github.com/rails/rails/issues/3471...
I fixed this issue by the following PR.
github.com/rails/spring/pull/679
That was a helpful tip, Alef. Thank you!