I'm working with Ruby on Rails in the creation process of an RestAPI, I create the application using this command:
rails _6.1.5_ new myproject --api
Now I need to add database support to the project, specifically I need to use PostgreSQL, so far I found this parameter but for new projects:
rails _6.1.5_ new myproject --api --database=postgresql
My question is: is there a way (parameter, command?) to add postgresql support to my existing project?
Thanks a lot
CodePudding user response:
If you want to change from sqlite to postgresql is simple, just add gem 'pg'
to Gemfile, then bundle install and after that change the default section of your database.yml
to:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>