#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
    CREATE USER ${POSTGRES_RUNTIME_USER:-latitude_app} WITH PASSWORD '${POSTGRES_RUNTIME_PASSWORD:-secret}';
    GRANT CONNECT ON DATABASE "$POSTGRES_DB" TO ${POSTGRES_RUNTIME_USER:-latitude_app};
EOSQL
