stravid/slotcars — pull request #149 by tombu (2012-04-27 12:56:15+00:00)
Title: Pull Request: chore/switch-to-postgres-in-development

If you are extremly interested watch the Railscast (http://railscasts.com/episodes/342-migrating-to-postgresql) otherwise use my instructions.

**OPTION 1: Homebrew (MacOSX)**
You need Ruby 1.8.x (Homebrew does not support Ruby 1.9.x). If you didn´t remove it, Ruby is basically installed on every Mac. Otherwise, you can install Ruby 1.8.7 using RVM or rubyenv and symlink it to the system´s ruby (`usr/bin/ruby`):
`> ln -s /Users/Thommy/.rvm/ruby-1.8.7-p352/bin/ruby /usr/bin/ruby`

`> brew install postgres`

If PostgreSQL is installed successfully, homebrew will show you further instructions.

Create DB cluster (which is owned by your default user):
`> initdb /usr/local/var/postgres`
Maybe you have to create the `var` directory by hand because of a `Permission denied - I had to :/
If you want to create a seperate user, e.g. `_postgresql`, read the comments on this page: http://www.postgresql.org/docs/9.0/interactive/postgres-user.html

To **start** the cluster enter:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

To **stop** the cluster enter:
pg_ctl -D /usr/local/var/postgres stop -s -m fast

Or create a LaunchAgent (cluster is started every time you boot your system):
`mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist`

**OPTION 2: PostgreSQL installer (MacOSX, Windows, Linux)**
Download the installer from: http://www.postgresql.org/download/
Take care of the user (I think `_postgres`) and the password. You have to insert these credentials in `config/configuration.yml`.

Now that the cluster is created and running, you need to run `bundle install` (removes sqlite gem and installs pg gem) and `rake db:create db:migrate db:seed` (to complete setup the database from ground)