Skip to content

Commit a2f1ff8

Browse files
soedirgopcnc
authored andcommitted
fix: only grant pg_read_all_data if it exists (#1242)
* fix: only grant pg_read_all_data if it exists * fix: prevent `public` from being casted into `regrole`
1 parent 5671a39 commit a2f1ff8

File tree

1 file changed

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

1 file changed

+10
-3
lines changed

Diff for: ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ begin
357357
, case when rec.grantee = 'postgres'::regrole then 'supabase_admin'
358358
when rec.grantee = 'supabase_admin'::regrole then 'postgres'
359359
when rec.grantee = 0 then 'public'
360-
else rec.grantee::regrole
360+
else rec.grantee::regrole::text
361361
end
362362
));
363363
end if;
@@ -383,7 +383,7 @@ begin
383383
when obj->>'objtype' = 'T' then 'types'
384384
when obj->>'objtype' = 'n' then 'schemas'
385385
end
386-
, case when rec.grantee = 0 then 'public' else rec.grantee::regrole end
386+
, case when rec.grantee = 0 then 'public' else rec.grantee::regrole::text end
387387
, case when rec.is_grantable then 'with grant option' else '' end
388388
));
389389
end if;
@@ -530,7 +530,14 @@ $$;
530530
alter database postgres connection limit -1;
531531
532532
-- #incident-2024-09-12-project-upgrades-are-temporarily-disabled
533-
grant pg_read_all_data, pg_signal_backend to postgres;
533+
do $$
534+
begin
535+
if exists (select from pg_authid where rolname = 'pg_read_all_data') then
536+
execute('grant pg_read_all_data to postgres');
537+
end if;
538+
end
539+
$$;
540+
grant pg_signal_backend to postgres;
534541
535542
set session authorization supabase_admin;
536543
drop role supabase_tmp;

0 commit comments

Comments
 (0)