commit 9ae7cc2226430968c346e9c864ae0111ffec95a5 from: Omar Polo date: Tue Mar 05 09:28:14 2024 UTC add localpg() commit - b952b33838a64296da3fd85c811b0938a32d0569 commit + 9ae7cc2226430968c346e9c864ae0111ffec95a5 blob - 089413ae5a3d9ceb36e8b491f7406980862be2eb blob + 433f97aaa0e8e9a4affdcd824d3770250fd60213 --- kshrc.lp +++ kshrc.lp @@ -297,3 +297,20 @@ implementation is completely different. find "$dir" $type -iname "$name" -exec "$@" {} + fi } + +Sometimes it's useful to have a local postgresql database for testing. I've stolen this trick from +=> https://jamey.thesharps.us/2019/05/29/per-project-postgres/ Jamey Thesharps "Per-project postgres" blog post + + localpg() { + export PGDATA="$(pwd)/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 + }