4 # Place the data directory inside the project directory
5 export PGDATA
="$(pwd)/postgres_dev-13"
7 envname
="$(basename "${PGDATA}")"
9 # Place Postgres' Unix socket inside the data directory
10 export PGHOST
="$PGDATA"
12 if [[ ! -d "$PGDATA" ]]; then
13 # If the data directory doesn't exist, create an empty one, and...
14 initdb
--data-checksums
15 # ...configure it to listen only on the Unix socket, and...
16 cat >> "$PGDATA/postgresql.conf" <<-EOF
18 unix_socket_directories = '$PGHOST'
19 shared_preload_libraries = 'pg_stat_statements'
21 # ...create a database using the name Postgres defaults to.
22 echo "CREATE DATABASE $USER;" | postgres
--single -E postgres
25 export PS1
="(${envname})${PS1}"
29 # ex: pg_ctl -l "${PGDATA}/logfile" start