Skip to content

Instantly share code, notes, and snippets.

@setomits
Created April 13, 2019 09:06
Show Gist options
  • Save setomits/e3816dae4720948dc909eccacd2a6943 to your computer and use it in GitHub Desktop.
Save setomits/e3816dae4720948dc909eccacd2a6943 to your computer and use it in GitHub Desktop.
function startpg
if test -z (docker ps --filter name=mypostgresql --quiet)
echo "Start PostgreSQL container"
docker run --rm --detach --publish 15432:5432 \
--name mypostgresql \
--volume (pwd)/db:/var/lib/postgresql/data \
postgres
echo -n "Starting PostfreSQL process "
while test -z $PG_READY
set PG_READY (psql --host localhost --port 15432 \
--username postgres \
--tuples-only --no-align \
--command 'select 1;' ^ /dev/null)
echo -n "."
sleep 1
end
echo
echo "PostgreSQL started"
echo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment