Skip to content

Commit 4b0e661

Browse files
dragarciadarora
authored andcommitted
chore: standardize
1 parent a627e17 commit 4b0e661

File tree

1 file changed

+10
-10
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+10
-10
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ MOUNT_POINT="/data_migration"
3939
LOG_FILE="/var/log/pg-upgrade-initiate.log"
4040

4141
POST_UPGRADE_EXTENSION_SCRIPT="/tmp/pg_upgrade/pg_upgrade_extensions.sql"
42-
POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT="/tmp/pg_upgrade/pg_upgrade_pgbouncer_cleanup.sql"
42+
POST_UPGRADE_POSTGRES_PERMS_SCRIPT="/tmp/pg_upgrade/pg_upgrade_postgres_perms.sql"
4343
OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")
4444

4545
SERVER_LC_COLLATE=$(run_sql -A -t -c "SHOW lc_collate;")
@@ -134,19 +134,19 @@ cleanup() {
134134
retry 5 run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
135135

136136
echo "Making sure postgres still has access to pg_shadow"
137-
cat << EOF >> $POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT
137+
cat << EOF >> $POST_UPGRADE_POSTGRES_PERMS_SCRIPT
138138
DO \$\$
139-
BEGIN
140-
IF EXISTS (SELECT 1 FROM pg_views WHERE viewname = 'pg_shadow' AND viewowner = 'supabase_admin') THEN
141-
ALTER function pgbouncer.get_auth owner to supabase_admin;
142-
GRANT EXECUTE ON FUNCTION pgbouncer.get_auth(p_usename TEXT) TO postgres;
143-
END IF;
144-
END;
139+
begin
140+
if exists (select from pg_authid where rolname = 'pg_read_all_data') then
141+
execute('grant pg_read_all_data to postgres');
142+
end if;
143+
end
145144
\$\$;
145+
grant pg_signal_backend to postgres;
146146
EOF
147147

148-
if [ -f $POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT ]; then
149-
retry 5 run_sql -f $POST_UPGRADE_PGBOUNCER_CLEANUP_SCRIPT
148+
if [ -f $POST_UPGRADE_POSTGRES_PERMS_SCRIPT ]; then
149+
retry 5 run_sql -f $POST_UPGRADE_POSTGRES_PERMS_SCRIPT
150150
fi
151151

152152
if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then

0 commit comments

Comments
 (0)