File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 4141 end if;
4242end $$;
4343
44+ -- For logical backups we detach the queue and archive tables from the pgmq extension
45+ -- prior to pausing. Once detached, pgmq.drop_queue breaks. This re-attaches them
46+ -- when a project is unpaused and allows pgmq.drop_queue to work normally.
47+ do $$
48+ declare
49+ ext_exists boolean ;
50+ tbl record;
51+ begin
52+ -- check if pgmq extension is installed
53+ select exists(select 1 from pg_extension where extname = ' pgmq' ) into ext_exists;
54+
55+ if ext_exists then
56+ for tbl in
57+ select c .relname as table_name
58+ from pg_class c
59+ join pg_namespace n on c .relnamespace = n .oid
60+ where n .nspname = ' pgmq'
61+ and c .relkind in (' r' , ' u' ) -- include ordinary and unlogged tables
62+ and (c .relname like ' q\_ %' or c .relname like ' a\_ %' )
63+ and c .oid not in (
64+ select d .objid
65+ from pg_depend d
66+ join pg_extension e on d .refobjid = e .oid
67+ where e .extname = ' pgmq'
68+ and d .classid = ' pg_class' ::regclass
69+ and d .deptype = ' e'
70+ )
71+ loop
72+ execute format(' alter extension pgmq add table pgmq.%I' , tbl .table_name );
73+ end loop;
74+ end if;
75+ end;
76+ $$;
77+
78+
4479-- migrate:down
You can’t perform that action at this time.
0 commit comments