Switch from sqlite3 to PostgreSQL

Ruby on Rails — Onkey Website Project

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: 5000
development:
<<: *default
database: onkey_website_development
test:
<<: *default
database: onkey_website_test
production:
<<: *default
database: onkey_website_production
  • Run rake db:create
  • Run rake db:migrate
  • Run rake db:seed(if you have a seed file)

All Set!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response