32 lines
826 B
SQL
32 lines
826 B
SQL
|
|
-- create tables
|
|
|
|
CREATE TABLE messages (
|
|
id bigserial NOT NULL primary key,
|
|
domain text,
|
|
action text,
|
|
class text,
|
|
item text,
|
|
sender text,
|
|
payload jsonb,
|
|
tstamp timestamptz default current_timestamp,
|
|
tsread timestamptz -- to be updated upon reading/processing of message
|
|
);
|
|
|
|
CREATE TABLE responses (
|
|
id bigserial NOT NULL primary key,
|
|
domain text,
|
|
action text,
|
|
class text,
|
|
item text,
|
|
payload jsonb,
|
|
tstamp timestamptz default current_timestamp
|
|
);
|
|
|
|
-- indexes
|
|
|
|
CREATE INDEX idx_msg ON messages USING btree (domain, action, class, item);
|
|
CREATE INDEX idx_msg_item ON messages USING btree (domain, class, item);
|
|
--CREATE INDEX idx_msg_action ON messages USING btree (action); -- obsolete
|
|
|
|
CREATE INDEX idx_resp_item ON responses USING btree (domain, class, item);
|