group_events

append-only added|removed|touched events per (group, identity)

What you'll learn

You're writing SQL that reads group_events and need its columns, what each holds, and the DDL as the spec states it.

  • every column and its type
  • what the object holds and who writes it
  • the DDL as the spec states it

A table. append-only added|removed|touched events per (group, identity)

Columns

ColumnTypeConstraints
idTEXTPRIMARY KEY
group_idTEXTNOT NULL REFERENCES groups(id)
identity_idTEXTNOT NULL REFERENCES identities(id)
eventTEXTNOT NULL
detailTEXT
run_idTEXT
created_atTEXTNOT NULL

Definition

From spec/ledger.sql, which is the machine-checkable form of SPEC.md §3:

CREATE TABLE group_events (
  id          TEXT PRIMARY KEY,          -- ULID
  group_id    TEXT NOT NULL REFERENCES groups(id),
  identity_id TEXT NOT NULL REFERENCES identities(id),
  event       TEXT NOT NULL,             -- 'added' | 'removed' | 'touched'
  detail      TEXT,                      -- JSON provenance
  run_id      TEXT,                      -- nullable: hand edits have no run
  created_at  TEXT NOT NULL
);
CREATE INDEX ix_ge_lookup ON group_events(group_id, identity_id, event, created_at DESC);