Skip to content

Commit a714e9a

Browse files
committed
chore: run post-upgrade vacuum_db as superuser
1 parent 7610c6a commit a714e9a

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
@@ -124,8 +124,8 @@ cleanup() {
124124
fi
125125

126126
echo "Re-enabling extensions"
127-
if [ -f $POST_UPGRADE_EXTENSION_SCRIPT ]; then
128-
run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
127+
if [ -f "$POST_UPGRADE_EXTENSION_SCRIPT" ]; then
128+
run_sql -f "$POST_UPGRADE_EXTENSION_SCRIPT"
129129
fi
130130

131131
echo "Removing SUPERUSER grant from postgres"
@@ -146,15 +146,15 @@ cleanup() {
146146
}
147147

148148
function handle_extensions {
149-
rm -f $POST_UPGRADE_EXTENSION_SCRIPT
150-
touch $POST_UPGRADE_EXTENSION_SCRIPT
149+
rm -f "$POST_UPGRADE_EXTENSION_SCRIPT"
150+
touch "$POST_UPGRADE_EXTENSION_SCRIPT"
151151

152152
PASSWORD_ENCRYPTION_SETTING=$(run_sql -A -t -c "SHOW password_encryption;")
153153
if [ "$PASSWORD_ENCRYPTION_SETTING" = "md5" ]; then
154-
echo "ALTER SYSTEM SET password_encryption = 'md5';" >> $POST_UPGRADE_EXTENSION_SCRIPT
154+
echo "ALTER SYSTEM SET password_encryption = 'md5';" >> "$POST_UPGRADE_EXTENSION_SCRIPT"
155155
fi
156156

157-
cat << EOF >> $POST_UPGRADE_EXTENSION_SCRIPT
157+
cat << EOF >> "$POST_UPGRADE_EXTENSION_SCRIPT"
158158
ALTER SYSTEM SET jit = off;
159159
SELECT pg_reload_conf();
160160
EOF
@@ -166,7 +166,7 @@ EOF
166166
if [ "$EXTENSION_ENABLED" = "t" ]; then
167167
echo "Disabling extension ${EXTENSION}"
168168
run_sql -c "DROP EXTENSION IF EXISTS ${EXTENSION} CASCADE;"
169-
cat << EOF >> $POST_UPGRADE_EXTENSION_SCRIPT
169+
cat << EOF >> "$POST_UPGRADE_EXTENSION_SCRIPT"
170170
DO \$\$
171171
BEGIN
172172
IF EXISTS (SELECT 1 FROM pg_available_extensions WHERE name = '${EXTENSION}') THEN

0 commit comments

Comments
 (0)