lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

0000_local_events.up.sql (1914B)


      1 create table if not exists local_event_record (
      2   seq integer primary key autoincrement,
      3   record_id text not null unique,
      4   family text not null check (family in ('local_work', 'signed_event')),
      5   status text not null check (status in ('local_draft', 'local_saved', 'pending_publish', 'published', 'failed', 'conflict')),
      6   source_runtime text not null check (source_runtime in ('cli', 'app', 'network', 'service', 'worker', 'test')),
      7   created_at_ms integer not null,
      8   inserted_at_ms integer not null,
      9   updated_at_ms integer not null,
     10   owner_account_id text,
     11   owner_pubkey text,
     12   farm_id text,
     13   listing_addr text,
     14   local_work_json text,
     15   event_id text,
     16   event_kind integer,
     17   event_pubkey text,
     18   event_created_at integer,
     19   event_tags_json text,
     20   event_content text,
     21   event_sig text,
     22   raw_event_json text,
     23   outbox_status text not null check (outbox_status in ('none', 'pending', 'acknowledged', 'failed')),
     24   relay_set_fingerprint text,
     25   relay_delivery_json text,
     26   check (trim(record_id) <> ''),
     27   check (family <> 'local_work' or local_work_json is not null),
     28   check (family <> 'local_work' or outbox_status = 'none'),
     29   check (family <> 'signed_event' or (event_id is not null and event_kind is not null and event_pubkey is not null and event_sig is not null and raw_event_json is not null))
     30 );
     31 
     32 create index if not exists local_event_record_event_id_idx on local_event_record(event_id);
     33 create index if not exists local_event_record_listing_addr_idx on local_event_record(listing_addr);
     34 create index if not exists local_event_record_owner_pubkey_idx on local_event_record(owner_pubkey);
     35 create index if not exists local_event_record_status_idx on local_event_record(status);
     36 
     37 create table if not exists local_event_projection_cursor (
     38   consumer_id text primary key,
     39   last_seq integer not null,
     40   updated_at_ms integer not null,
     41   check (trim(consumer_id) <> ''),
     42   check (last_seq >= 0)
     43 );