create table messages (
    id integer not null primary key,
    domain text,
    action text,
    class text,
    item text,
    sender text,
    payload jsonb,
    tstamp timestamptz default current_timestamp
);

-- indexes

create index idx_msg on messages (domain, action, class, item);
create index idx_msg_item on messages (domain, class, item);
--create index idx_msg_action on messages using btree (action); -- obsolete

