Skip to content

Commit d3a63c2

Browse files
committed
chore: run post-upgrade vacuum_db as superuser
1 parent ba5db1c commit d3a63c2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/complete.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ function start_vacuum_analyze {
173173
if ! command -v nix &> /dev/null; then
174174
su -c 'vacuumdb --all --analyze-in-stages' -s "$SHELL" postgres
175175
else
176-
su -c '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && vacuumdb --all --analyze-in-stages' -s "$SHELL" postgres
176+
# shellcheck disable=SC1091
177+
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
178+
vacuumdb --all --analyze-in-stages -U supabase_admin -h localhost -p 5432
177179
fi
178180
echo "Upgrade job completed"
179181
}

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ cleanup() {
120120
fi
121121

122122
echo "Re-enabling extensions"
123-
if [ -f $POST_UPGRADE_EXTENSION_SCRIPT ]; then
124-
run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
123+
if [ -f "$POST_UPGRADE_EXTENSION_SCRIPT" ]; then
124+
run_sql -f "$POST_UPGRADE_EXTENSION_SCRIPT"
125125
fi
126126

127127
echo "Removing SUPERUSER grant from postgres"
@@ -142,15 +142,15 @@ cleanup() {
142142
}
143143

144144
function handle_extensions {
145-
rm -f $POST_UPGRADE_EXTENSION_SCRIPT
146-
touch $POST_UPGRADE_EXTENSION_SCRIPT
145+
rm -f "$POST_UPGRADE_EXTENSION_SCRIPT"
146+
touch "$POST_UPGRADE_EXTENSION_SCRIPT"
147147

148148
PASSWORD_ENCRYPTION_SETTING=$(run_sql -A -t -c "SHOW password_encryption;")
149149
if [ "$PASSWORD_ENCRYPTION_SETTING" = "md5" ]; then
150-
echo "ALTER SYSTEM SET password_encryption = 'md5';" >> $POST_UPGRADE_EXTENSION_SCRIPT
150+
echo "ALTER SYSTEM SET password_encryption = 'md5';" >> "$POST_UPGRADE_EXTENSION_SCRIPT"
151151
fi
152152

153-
cat << EOF >> $POST_UPGRADE_EXTENSION_SCRIPT
153+
cat << EOF >> "$POST_UPGRADE_EXTENSION_SCRIPT"
154154
ALTER SYSTEM SET jit = off;
155155
SELECT pg_reload_conf();
156156
EOF
@@ -162,7 +162,7 @@ EOF
162162
if [ "$EXTENSION_ENABLED" = "t" ]; then
163163
echo "Disabling extension ${EXTENSION}"
164164
run_sql -c "DROP EXTENSION IF EXISTS ${EXTENSION} CASCADE;"
165-
cat << EOF >> $POST_UPGRADE_EXTENSION_SCRIPT
165+
cat << EOF >> "$POST_UPGRADE_EXTENSION_SCRIPT"
166166
DO \$\$
167167
BEGIN
168168
IF EXISTS (SELECT 1 FROM pg_available_extensions WHERE name = '${EXTENSION}') THEN

0 commit comments

Comments
 (0)