pgmq-migration-0.1.1.0: database/v1.11.0/03_types.sql
------------------------------------------------------------
-- Custom types: message_record, queue_record, metrics_result
------------------------------------------------------------
-- This type has the shape of a message in a queue, and is often returned by
-- pgmq functions that return messages
-- Note: last_read_at field added in pgmq 1.10.0
CREATE TYPE pgmq.message_record AS (
msg_id BIGINT,
read_ct INTEGER,
enqueued_at TIMESTAMP WITH TIME ZONE,
last_read_at TIMESTAMP WITH TIME ZONE,
vt TIMESTAMP WITH TIME ZONE,
message JSONB,
headers JSONB
);
CREATE TYPE pgmq.queue_record AS (
queue_name VARCHAR,
is_partitioned BOOLEAN,
is_unlogged BOOLEAN,
created_at TIMESTAMP WITH TIME ZONE
);
-- returned by pgmq.metrics() and pgmq.metrics_all
CREATE TYPE pgmq.metrics_result AS (
queue_name text,
queue_length bigint,
newest_msg_age_sec int,
oldest_msg_age_sec int,
total_messages bigint,
scrape_time timestamp with time zone,
queue_visible_length bigint
);