ograph/packages/engine/migrations/0007_reducers.sql
小橘 d84a860d15 feat: initial ograph repo — engine (85 tests) + cli (31 tests)
Extracted from uncaged monorepo (oc-xiaoju/uncaged).
Resolves oc-xiaoju/uncaged#224.

- @uncaged/ograph: CF Worker engine (events, projections, reactions)
- @uncaged/ograph-cli: CLI for managing OGraph instances
- Removed @uncaged/oid dependency (unused)
- 116 tests, all passing
- CI: GitHub Actions

小橘 🍊(NEKO Team)
2026-04-12 23:43:56 +00:00

31 lines
811 B
SQL

CREATE TABLE reducers (
name TEXT PRIMARY KEY,
driven_by TEXT NOT NULL,
params TEXT NOT NULL,
filter TEXT NOT NULL,
expression TEXT NOT NULL,
mode TEXT NOT NULL DEFAULT 'fold' CHECK(mode IN ('fold', 'latest', 'window')),
window_size INTEGER,
initial_value TEXT
);
CREATE TABLE projections (
reducer TEXT NOT NULL REFERENCES reducers(name),
params TEXT NOT NULL,
params_hash TEXT NOT NULL,
value TEXT,
updated_by TEXT,
updated_at INTEGER,
live INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (reducer, params_hash)
);
CREATE TABLE event_log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
evt_oid TEXT NOT NULL,
processed_reducers TEXT,
processed_reactions TEXT,
created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
);
CREATE INDEX idx_event_log_created ON event_log(created_at);