Skip to content

Commit ee4acdf

Browse files
committed
ensure sequences owned by supabase_admin are xfered to postgres on restore
1 parent 047a2d7 commit ee4acdf

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

migrations/db/migrations/20241215003910_backfill_pgmq_metadata.sql

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ begin
3030
case when c.relpersistence = 'u' then true else false end as is_unlogged,
3131
now() as created_at
3232
from
33-
pg_catalog.pg_class c
34-
join pg_catalog.pg_namespace n
35-
on c.relnamespace = n.oid
33+
pg_catalog.pg_class c
34+
join pg_catalog.pg_namespace n
35+
on c.relnamespace = n.oid
3636
where
3737
n.nspname = 'pgmq'
3838
and c.relname like 'q_%'
@@ -41,4 +41,23 @@ begin
4141
end if;
4242
end $$;
4343

44+
do $$
45+
declare
46+
rec record;
47+
begin
48+
for rec in
49+
select n.nspname as sequence_schema, c.relname as sequence_name
50+
from pg_catalog.pg_class c
51+
join pg_catalog.pg_namespace n on n.oid = c.relnamespace
52+
join pg_catalog.pg_roles r on r.oid = c.relowner
53+
where
54+
c.relkind = 'S'
55+
and n.nspname = 'pgmq'
56+
and r.rolname = 'supabase_admin'
57+
loop
58+
execute format('alter sequence %I.%I owner to postgres', rec.sequence_schema, rec.sequence_name);
59+
end loop;
60+
end;
61+
$$;
62+
4463
-- migrate:down

0 commit comments

Comments
 (0)