Skip to content

Commit a232570

Browse files
committed
test
1 parent 169df47 commit a232570

File tree

1 file changed

+12
-2
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+12
-2
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ function initiate_upgrade {
316316
if [ "$OLD_BOOTSTRAP_USER" = "postgres" ]; then
317317
run_sql -c "create role supabase_tmp login superuser;"
318318
# TODO: move to its own file
319-
# TODO: GRANT TO postgres
320-
# TODO: GRANTED BY postgres
321319
psql -h localhost -U supabase_tmp -d postgres <<'EOSQL'
322320
do $$
323321
declare
@@ -332,6 +330,12 @@ declare
332330
join pg_authid a on a.oid = d.defaclrole
333331
left join pg_namespace n on n.oid = d.defaclnamespace
334332
);
333+
-- We only care about swapping init_privs for extensions
334+
init_privs jsonb[] := (
335+
select coalesce(array_agg(jsonb_build_object('objoid', objoid, 'classoid', classoid, 'initprivs', initprivs::text)), '{}')
336+
from pg_init_privs
337+
where privtype = 'e'
338+
);
335339
schemas jsonb[] := (
336340
select coalesce(array_agg(jsonb_build_object('oid', n.oid, 'owner', a.rolname, 'acl', nspacl::text)), '{}')
337341
from pg_namespace n
@@ -474,6 +478,12 @@ begin
474478
-- TODO: don't modify system catalog directly
475479
update pg_user_mapping set umuser = 'postgres'::regrole where umuser = 'supabase_admin'::regrole;
476480
481+
-- init privs
482+
foreach obj in array default_acls
483+
loop
484+
update pg_init_privs set initprivs = (obj->>'initprivs')::aclitem[] where objoid = (obj->>'objoid')::oid and classoid = (obj->>'classoid')::oid;
485+
end loop;
486+
477487
-- default acls
478488
foreach obj in array default_acls
479489
loop

0 commit comments

Comments
 (0)