Skip to content

Commit

Permalink
Use provided POSTGRES_USER environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
justinclift committed Oct 9, 2024
1 parent a7817cf commit e08fc14
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pgautoupgrade-postupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ 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}")
DB_LIST=$(echo 'SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE' | psql --username="${POSTGRES_USER}" -1t --csv "${POSTGRES_DB}")

# Update query planner statistics
echo "----------------------------"
echo "Updating query planner stats"
echo "----------------------------"

for DATABASE in ${DB_LIST}; do
echo "VACUUM (ANALYZE, VERBOSE, INDEX_CLEANUP FALSE)" | psql -t --csv "${DATABASE}"
echo "VACUUM (ANALYZE, VERBOSE, INDEX_CLEANUP FALSE)" | psql --username="${POSTGRES_USER}" -t --csv "${DATABASE}"
done

echo "-------------------------------------"
Expand All @@ -64,7 +64,7 @@ for DATABASE in ${DB_LIST}; do
echo "Starting reindex of ${DATABASE}"
echo "-------------------------------"

echo 'REINDEX DATABASE CONCURRENTLY' | psql -t --csv "${DATABASE}"
echo 'REINDEX DATABASE CONCURRENTLY' | psql --username="${POSTGRES_USER}" -t --csv "${DATABASE}"

echo "-------------------------------"
echo "Finished reindex of ${DATABASE}"
Expand Down

0 comments on commit e08fc14

Please sign in to comment.