A little note on how I setup and bootstrap local PostgreSQL databases on OS X machines.
Instructions below were tested on OS X El Capitan, and target the 9.4.x series of PostgreSQL.
Install and setup PostgreSQL:
1$ brew update
2$ brew install postgresql94 ossp-uuid
34
$ mkdir -p ~/Library/LaunchAgents
5$ cp /usr/local/Cellar/postgresql94/9.4.9_1/homebrew.mxcl.postgresql94.plist ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
6$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
78
$ rm -rf /usr/local/var/postgres
9$ initdb /usr/local/var/postgres -E utf8 --no-locale
1011
$ sed -i "s/^#port = 5432/port = 5432/" /usr/local/var/postgres/postgresql.conf
12$ sed -i "s/^#autovacuum = on/autovacuum = on/" /usr/local/var/postgres/postgresql.conf
13$ sed -i "s/timezone = 'Europe\/Paris'/timezone = 'UTC'/" /usr/local/var/postgres/postgresql.conf
14$ sed -i "s/log_timezone = 'Europe\/Paris'/log_timezone = 'UTC'/" /usr/local/var/postgres/postgresql.conf
1516
$ initdb /usr/local/var/postgres
1718
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Initialize PostgreSQL:
1$ dropdb test_db
23
$ createdb -E UTF8 -T template0 test_db
45
$ psql --command 'CREATE EXTENSION "citext";' --dbname=test_db
6$ psql --command 'CREATE EXTENSION "uuid-ossp";' --dbname=test_db
78
$ tail -F /usr/local/var/postgres/server.log
Load up a dumped database:
1 $ pg_restore --verbose --clean --no-acl --no-owner -h localhost -d test_db ~/dump/2016-10-10-test_db.dump