core/allow alternative postgres credentials

This commit allows the `dev-reset` command in the Makefile to pick up and use credentials from the
`.env` file if they are present, or fallback to the defaults provided if they are not. This is the
only place in the Makefile where the database credentials are used directly against postgresql
binaries. The syntax was tested with bash, zsh, and csh, and did not fail under those.

The `$${:-}` syntax is a combination of a Makefile idiom for "Pass a single `$` to the environment
where this command will be executed," and the shell expresion `${VARIABLE:-default}` means
"dereference the environment variable; if it is undefined, used the default value provided."
This commit is contained in:
Ken Sternberg 2023-09-25 12:50:59 -07:00
parent db2c0667a9
commit f691c6896f
1 changed files with 3 additions and 3 deletions

View File

@ -219,9 +219,9 @@ install: web-install website-install
poetry install
dev-reset:
dropdb -U postgres -h localhost authentik
dropdb -U $${PG_USER:-postgres} -h $${PG_HOST:-localhost} $${PG_DB:-authentik}
# Also remove the test-db if it exists
dropdb -U postgres -h localhost test_authentik || true
createdb -U postgres -h localhost authentik
dropdb -U $${PG_USER:-postgres} -h $${PG_HOST:-localhost} test_authentik || true
createdb -U $${PG_USER:-postgres} -h $${PG_HOST:-localhost} $${PG_DB:-authentik}
redis-cli -n 0 flushall
make migrate