diff --git a/migrations/db/migrations/20241215003910_backfill_pgmq_metadata.sql b/migrations/db/migrations/20241215003910_backfill_pgmq_metadata.sql index 652be2a1d..bcdc299e2 100644 --- a/migrations/db/migrations/20241215003910_backfill_pgmq_metadata.sql +++ b/migrations/db/migrations/20241215003910_backfill_pgmq_metadata.sql @@ -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_' 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 $$;