Skip to content

Instantly share code, notes, and snippets.

@willwright82
Last active September 22, 2022 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willwright82/9f234ecb7b82a8dd87119c04fe689146 to your computer and use it in GitHub Desktop.
Save willwright82/9f234ecb7b82a8dd87119c04fe689146 to your computer and use it in GitHub Desktop.
Swap out sqlite for postgres in a fresh Rails install

Gemfile

  • Delete the line with sqlite and replace it with:
gem 'pg'

database.yml

  • assuming your app name is "ror", replace with:
default: &default
  adapter: postgresql
  username:
  password:
  host: localhost

development:
  <<: *default
  database: ror_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: ror_test

production:
  <<: *default
  database: ror_production

Run:

bundle
bin/rake db:setup
bin/rake db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment