cpmdvg
Last Updated: May 15, 2019
·
3.373K
· mindeavor

Rails 3 development: Switch from sqlite3 to pg (postgresql)

This is mostly a note to myself, since I keep forgetting.

If you created a standard rails project, but later want to switch to using the pg gem, here's what you need to do:

WARNING: This method does not migrate old data.

In Gemfile:

group :development do
  # gem 'sqlite3'
  gem 'pg'
end

In database.yml:

development:
  # adapter: sqlite3
  # database: db/development.sqlite3
  host: localhost
  adapter: postgresql
  database: myapp_dev
  username: mydbuser

On the command line:

$ bundle install
$ bundle exec rake db:create db:migrate

2 Responses
Add your response

7848

I tried the following but was receiving a bunch of errors: https://gist.github.com/blklane/5994523, any ideas?

over 1 year ago ·
7850

blklane, my guess is that postgres is not running on your machine; you need to start it first.

over 1 year ago ·