Created
March 22, 2024 16:43
-
-
Save kennyp/50abe98f57c133e37dc2c883f965b455 to your computer and use it in GitHub Desktop.
Postgresql Layout for direnv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layout_postgres() { | |
export PGDATA="$(direnv_layout_dir)/postgres" | |
export PGHOST="$PGDATA" | |
if [[ ! -d "$PGDATA" ]]; then | |
initdb | |
cat >> "$PGDATA/postgresql.conf" <<-EOF | |
listen_addresses = '' | |
unix_socket_directories = '$PGHOST' | |
EOF | |
echo "CREATE DATABASE $USER;" | postgres --single -E postgres | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment