Proactively verify if psql and sqlx are installed before moving forward with script execution.

This commit is contained in:
Luca Palmieri 2021-07-05 08:55:57 +02:00
parent 6e31366fb2
commit 0c989497fc

View file

@ -2,6 +2,19 @@
set -x set -x
set -eo pipefail set -eo pipefail
if ! [ -x "$(command -v psql)" ]; then
echo >&2 "Error: `psql` is not installed."
exit 1
fi
if ! [ -x "$(command -v sqlx)" ]; then
echo >&2 "Error: `sqlx` is not installed."
echo >&2 "Use:"
echo >&2 " cargo install --version=0.5.5 sqlx-cli --no-default-features --features postgres"
echo >&2 "to install it."
exit 1
fi
# Check if a custom user has been set, otherwise default to 'postgres' # Check if a custom user has been set, otherwise default to 'postgres'
DB_USER="${POSTGRES_USER:=postgres}" DB_USER="${POSTGRES_USER:=postgres}"
# Check if a custom password has been set, otherwise default to 'password' # Check if a custom password has been set, otherwise default to 'password'