Skip to content

Commit 3c96465

Browse files
committed
test
1 parent dbe51c4 commit 3c96465

File tree

1 file changed

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

1 file changed

+9
-2
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ 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: GRANTED BY, ADMIN OPTION
319320
psql -h localhost -U supabase_tmp -d postgres <<'EOSQL'
320321
do $$
321322
declare
@@ -465,10 +466,16 @@ begin
465466
foreach obj in array schemas
466467
loop
467468
if obj->>'owner' = 'postgres' then
468-
execute(format('alter schema %s owner to postgres;', (obj->>'oid')::regnamespace));
469+
execute(format('alter schema %I owner to postgres;', (obj->>'oid')::regnamespace));
469470
end if;
470471
-- TODO: don't modify system catalog directly
471-
update pg_namespace set nspacl = (obj->>'acl')::aclitem[] where nspname = obj->>'oid';
472+
for rec in
473+
select grantor, grantee, privilege_type, is_grantable
474+
from aclexplode((obj->>'acl')::aclitem[])
475+
where grantee = 'supabase_admin'::regrole
476+
loop
477+
execute(format('grant %s on schema %s to postgres %s', rec.privilege_type, (obj->>'oid')::regnamespace, case when rec.is_grantable then 'with grant option' else '' end));
478+
end loop;
472479
end loop;
473480
474481
-- types

0 commit comments

Comments
 (0)