Switch from sqlite3 to PostgreSQL
Ruby on Rails — Onkey Website Project
Sep 2, 2021
Install Postgres
Before getting started, make sure to download the Postgre for macOS from the official website.
Update Gemfile
Remove sqlite3:
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
And add Postgres:
# Use Postgres as the database for Active Record
gem 'pg'
Once you’ve updated your Gemfile, run bundle install
to update your Gemfile.lock file.
Edit files
Change settings in config/database.yml
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000development:
<<: *default
database: onkey_website_developmenttest:
<<: *default
database: onkey_website_testproduction:
<<: *default
database: onkey_website_production
- Run
rake db:create
- Run
rake db:migrate
- Run
rake db:seed
(if you have a seed file)