Skip to content

Commit 4beda6e

Browse files
committed
test
1 parent 360c51c commit 4beda6e

File tree

1 file changed

+13
-7
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+13
-7
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,18 @@ declare
326326
postgres_role_settings text[] := (select setconfig from pg_db_role_setting where setdatabase = 0 and setrole = 'postgres'::regrole);
327327
supabase_admin_role_settings text[] := (select setconfig from pg_db_role_setting where setdatabase = 0 and setrole = 'supabase_admin'::regrole);
328328
schemas jsonb[] := (
329-
select coalesce(array_agg(jsonb_build_object('oid', oid, 'owner', nspowner::regrole, 'acl', nspacl::text)), '{}')
330-
from pg_namespace
329+
select coalesce(array_agg(jsonb_build_object('oid', n.oid, 'owner', a.rolname, 'acl', nspacl::text)), '{}')
330+
from pg_namespace n
331+
join pg_authid a on a.oid = n.nspowner
331332
where true
332-
and nspname != 'information_schema'
333-
and not starts_with(nspname, 'pg_')
333+
and n.nspname != 'information_schema'
334+
and not starts_with(n.nspname, 'pg_')
334335
);
335336
types jsonb[] := (
336-
select coalesce(array_agg(jsonb_build_object('oid', t.oid, 'acl', t.typacl::text)), '{}')
337+
select coalesce(array_agg(jsonb_build_object('oid', t.oid, 'owner', a.rolname, 'acl', t.typacl::text)), '{}')
337338
from pg_type t
338339
join pg_namespace n on n.oid = t.typnamespace
340+
join pg_authid a on a.oid = t.typowner
339341
where true
340342
and n.nspname != 'information_schema'
341343
and not starts_with(n.nspname, 'pg_')
@@ -360,20 +362,24 @@ declare
360362
)
361363
);
362364
functions jsonb[] := (
363-
select coalesce(array_agg(jsonb_build_object('oid', p.oid, 'acl', p.proacl::text)), '{}')
365+
select coalesce(array_agg(jsonb_build_object('oid', p.oid, 'owner', a.rolname, 'acl', p.proacl::text)), '{}')
364366
from pg_proc p
365367
join pg_namespace n on n.oid = p.pronamespace
368+
join pg_authid a on a.oid = p.proowner
366369
where true
367370
and n.nspname != 'information_schema'
368371
and not starts_with(n.nspname, 'pg_')
372+
and a.rolname = 'postgres'
369373
);
370374
relations jsonb[] := (
371-
select coalesce(array_agg(jsonb_build_object('oid', c.oid, 'acl', c.relacl::text)), '{}')
375+
select coalesce(array_agg(jsonb_build_object('oid', c.oid, 'owner', a.rolname, 'acl', c.relacl::text)), '{}')
372376
from pg_class c
373377
join pg_namespace n on n.oid = c.relnamespace
378+
join pg_authid a on a.oid = c.relowner
374379
where true
375380
and n.nspname != 'information_schema'
376381
and not starts_with(n.nspname, 'pg_')
382+
and a.rolname = 'postgres'
377383
and c.relkind not in ('c', 'i')
378384
);
379385
rec record;

0 commit comments

Comments
 (0)