Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ begin
-- Check if the pgmq.meta table exists
if exists (
select 1
from pg_catalog.pg_class c
join pg_catalog.pg_namespace n on c.relnamespace = n.oid
where n.nspname = 'pgmq' and c.relname = 'meta'
from pg_catalog.pg_class cls
join pg_catalog.pg_namespace ns on cls.relnamespace = ns.oid
where ns.nspname = 'pgmq' and cls.relname = 'meta'
) then
-- Insert data into pgmq.meta for all tables matching the naming pattern 'pgmq.q_<queue_name>'
insert into pgmq.meta (queue_name, is_partitioned, is_unlogged, created_at)
select
substring(c.relname from 3) as queue_name,
substring(cls.relname from 3) as queue_name,
false as is_partitioned,
case when c.relpersistence = 'u' then true else false end as is_unlogged,
case when cls.relpersistence = 'u' then true else false end as is_unlogged,
now() as created_at
from
pg_catalog.pg_class c
join pg_catalog.pg_namespace n
on c.relnamespace = n.oid
pg_catalog.pg_class cls
join pg_catalog.pg_namespace ns
on cls.relnamespace = ns.oid
where
n.nspname = 'pgmq'
and c.relname like 'q_%'
and c.relkind in ('r', 'p', 'u');
ns.nspname = 'pgmq'
and cls.relname like 'q_%'
and cls.relkind in ('r', 'p', 'u');
end if;
end $$;

Expand Down
Loading