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
Written by Gilbert
Related protips
2 Responses
I tried the following but was receiving a bunch of errors: https://gist.github.com/blklane/5994523, any ideas?
over 1 year ago
·
blklane, my guess is that postgres is not running on your machine; you need to start it first.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#