-- Stores serialized CRDT SignedOps for pipeline state persistence.
-- On startup, all ops are replayed in sequence order to reconstruct the CRDT document.
CREATE TABLE IF NOT EXISTS crdt_ops (
    op_id   TEXT    PRIMARY KEY,
    seq     INTEGER NOT NULL,
    op_json TEXT    NOT NULL,
    created_at TEXT NOT NULL
);

-- Stores the node keypair seed so the same identity survives restarts.
CREATE TABLE IF NOT EXISTS crdt_node_identity (
    id   INTEGER PRIMARY KEY CHECK (id = 1),
    seed BLOB    NOT NULL
);
