Skip to content

Instantly share code, notes, and snippets.

@beneggett
Created February 5, 2014 21:46
Show Gist options
  • Save beneggett/8833843 to your computer and use it in GitHub Desktop.
Save beneggett/8833843 to your computer and use it in GitHub Desktop.
Migrating to Postgresql from another DB
development:
adapter: postgresql
database: my_site_development
username: ben
password:
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_site_test
username: ben
password:
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_site_production
username: ben
password:
pool: 5
timeout: 5000
# ...
gem 'pg'
# bundle install after, make sure you remove sqlite3, or other db gems
# ...

Setup a new database with postgresql

Make sure Postgresql is installed on our system

To install:

brew install postgresql

To verify:

brew list

and postgresql should be in that list.

Setup the default postgres database

initdb /usr/local/var/postgres -E utf8

Verify Install succeeded

psql -d postgres `whoami`

Update database.yml

Put in your username/password as applicable (see attached database.yml file)

Create database and run migrations

rake db:create
rake db:migrate

Verify its working

Open your server, or rails console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment