@@ -39,7 +39,7 @@ MOUNT_POINT="/data_migration"
3939LOG_FILE=" /var/log/pg-upgrade-initiate.log"
4040
4141POST_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"
4343OLD_PGVERSION=$( run_sql -A -t -c " SHOW server_version;" )
4444
4545SERVER_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
138138DO \$\$
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;
146146EOF
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