Skip to content

Commit

Permalink
Don't hard code the postgres database name
Browse files Browse the repository at this point in the history
  • Loading branch information
justinclift committed Oct 3, 2024
1 parent 93c5fd8 commit e8a81ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ _main() {
else
# If the upgrade process ran, then we need to launch the post-upgrade script in the background while PG runs
if [ "${UPGRADE_PERFORMED}" -eq 1 ]; then
/usr/local/bin/pgautoupgrade-postupgrade.sh "${PGDATA}" "${PGAUTO_ONESHOT}" 2>&1 &
/usr/local/bin/pgautoupgrade-postupgrade.sh "${PGDATA}" "${POSTGRES_DB}" "${PGAUTO_ONESHOT}" 2>&1 &
echo "****************************"
echo "Post upgrade script launched"
echo "****************************"
Expand Down
9 changes: 5 additions & 4 deletions pgautoupgrade-postupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

set -e

if [ $# -ne 2 ]; then
echo "Required number of arguments not passed to post upgrade script. 2 expected, $# received"
if [ $# -ne 3 ]; then
echo "Required number of arguments not passed to post upgrade script. 3 expected, $# received"
exit 1
fi

PGDATA=$1
PGAUTO_ONESHOT=$2
POSTGRES_DB=$2
PGAUTO_ONESHOT=$3

# Wait for PostgreSQL to start and become available
COUNT=0
Expand Down Expand Up @@ -37,7 +38,7 @@ if [ $RUNNING -ne 0 ]; then
fi

# Get the list of databases in the database cluster
DB_LIST=$(echo 'SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE' | psql -1t --csv postgres)
DB_LIST=$(echo 'SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE' | psql -1t --csv "${POSTGRES_DB}")

# Update query planner statistics
echo "----------------------------"
Expand Down

0 comments on commit e8a81ee

Please sign in to comment.