@@ -316,8 +316,6 @@ function initiate_upgrade {
316
316
if [ " $OLD_BOOTSTRAP_USER " = " postgres" ]; then
317
317
run_sql -c " create role supabase_tmp login superuser;"
318
318
# TODO: move to its own file
319
- # TODO: GRANT TO postgres
320
- # TODO: GRANTED BY postgres
321
319
psql -h localhost -U supabase_tmp -d postgres << 'EOSQL '
322
320
do $$
323
321
declare
@@ -332,6 +330,12 @@ declare
332
330
join pg_authid a on a.oid = d.defaclrole
333
331
left join pg_namespace n on n.oid = d.defaclnamespace
334
332
);
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
+ );
335
339
schemas jsonb[] := (
336
340
select coalesce(array_agg(jsonb_build_object('oid', n.oid, 'owner', a.rolname, 'acl', nspacl::text)), '{}')
337
341
from pg_namespace n
@@ -474,6 +478,12 @@ begin
474
478
-- TODO: don't modify system catalog directly
475
479
update pg_user_mapping set umuser = 'postgres'::regrole where umuser = 'supabase_admin'::regrole;
476
480
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
+
477
487
-- default acls
478
488
foreach obj in array default_acls
479
489
loop
0 commit comments