add scopes subdirectory for (cl-, go-, py-) -scopes storage (tracking) formats

This commit is contained in:
Helmut Merz 2025-09-15 12:40:21 +02:00
parent 41a8dd9af8
commit af16128a24
4 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,6 @@
-- scopes: compat_msgstore
-- rename columns from go-storage/emsgstore:messages to scopes:messages
alter table messages rename id to trackid;
alter table messages rename tstamp to timestamp;
alter table messages rename payload to data;

4
pgsql/scopes/drop.sql Normal file
View file

@ -0,0 +1,4 @@
-- drop tables
drop table messages;

15
pgsql/scopes/tables.sql Normal file
View file

@ -0,0 +1,15 @@
-- scopes: create tables (and other table-related stuff)
CREATE TABLE messages (
trackid bigserial NOT NULL primary key,
domain text,
action text,
class text,
item text,
timestamp timestamptz default current_timestamp,
data jsonb
);
CREATE INDEX idx_msg ON messages USING btree (domain, action, class, item);
CREATE INDEX idx_msg_item ON messages USING btree (domain, class, item);

9
pgsql/scopes/views.sql Normal file
View file

@ -0,0 +1,9 @@
-- scopes: create views
create or replace view messages_current as
select trackid, domain, action, class, item, timestamp, data
from messages m1
where trackid = (select max(trackid) from messages m2
where m2.domain = m1.domain and m2.action = m1.action
and m2.class = m1.class and m2.item = m1.item);