Skip to content

Instantly share code, notes, and snippets.

@phinze
Created January 29, 2013 19:38
Show Gist options
  • Save phinze/4667015 to your computer and use it in GitHub Desktop.
Save phinze/4667015 to your computer and use it in GitHub Desktop.
In memory postgres database. First cut. Adapted from https://github.com/okfn/ckan/blob/master/bin/osx-postgres-mem.sh
#!/bin/sh
## set up postgres (in this case 9.0 from macports
export PGCTL=/usr/local/bin/pg_ctl
export PGDATA=/Volumes/pgtmp/postgres
case $1 in
start)
## Make a RAM filesystem
diskutil erasevolume HFS+ "pgtmp" `hdiutil attach -nomount ram://1048576`
## start postgres
${PGCTL} -D ${PGDATA} init
${PGCTL} -D ${PGDATA} start
sleep 2;
;;
stop)
## stop postgres
${PGCTL} -D ${PGDATA} stop
## poof!
umount /Volumes/pgtmp
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment