Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP. Initial code to automatically upgrade PG database extensions #53

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions pgautoupgrade-postupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,40 @@ echo "-------------------------------"
echo "End of reindexing the databases"
echo "-------------------------------"

# Update the extensions
echo "-----------------------"
echo "Updating the extensions"
echo "-----------------------"

# For each database, update its extensions
for DATABASE in ${DB_LIST}; do
echo "-----------------------------------------"
echo "Starting extension update for ${DATABASE}"
echo "-----------------------------------------"

EXTENSION_LIST=$(echo 'SELECT name FROM pg_catalog.pg_available_extensions WHERE default_version <> installed_version' | psql -t --csv "${DATABASE}")

for EXTENSION in ${EXTENSION_LIST}; do
echo "-------------------------------"
echo "Updating extension ${EXTENSION}"
echo "-------------------------------"

echo 'ALTER EXTENSION foobar UPDATE' | psql -t --csv "${DATABASE}"

echo "----------------------------------------"
echo "Finished updating extension ${EXTENSION}"
echo "----------------------------------------"
done

echo "-----------------------------------------"
echo "Finished extension update for ${DATABASE}"
echo "-----------------------------------------"
done

echo "--------------------------------"
echo "Finished updating the extensions"
echo "--------------------------------"

# If "one shot" mode was requested, then shut down PostgreSQL
if [ "x${PGAUTO_ONESHOT}" = "xyes" ]; then
echo "****************************************************************************************************"
Expand Down