Start/stop postgres per project

27 views Asked by At

I have several projects that use different versions of Postgres. We're using the asdf plugin to configure them. It's annoying to have to start and stop Postgres each time I move to different project. Is there some way to automate this? I was looking at adding it to our development Procfile, but since the pg_ctl process exits immediately after starting the server, foreman also exits.

1

There are 1 answers

0
lobati On

My current solution is to add an alias that starts the database before running foreman and shuts it down afterwards. It's not perfect, since it means I need to boot up the server in order to run the tests:

alias fsd="pg_ctl start && foreman start -f Procfile.dev; pg_ctl stop"