document_history_checkpoints Client SQLite table
Full-history persistence for local documents (checkpoint + tail) — the ONLY durable content source. Record rows in documents carry runtime metadata and the content frontier (snapshotEndVersion), never content. The checkpoint holds a full-history snapshot refreshed only at compaction, and the tail appends every update (local deltas and decrypted remote updates) written since. Restore = import checkpoint + replay tail; compaction = export full history from the live doc, replace the checkpoint, clear the tail — all bounded and amortized. Container metadata stores its content (an exported-updates blob) as its checkpoint row, with no tail.
Declared in packages/client-sdk/src/data/sqlite/schema/documentRecordSchema.ts
Columns
app_kindtext- not null
Document scope matching
documents; one checkpoint per scope.local_idtext- not null
Document scope matching
documents; one checkpoint per scope.snapshottext- not null
Base64 Loro full-history snapshot; for container metadata, the base64 updates export.
end_version_vectortext- not null
Base64-encoded Loro version vector the snapshot covers. An unforced replacement of a document checkpoint must cover it too.
revisiontext- not null
Token replaced on every write. A document checkpoint replacement applies only while the random UUID it read is still stored, so a concurrent writer that replaced the row first wins. Container metadata, replaced with its record, reuses
updatedAt.updated_attext- not null
ISO-8601 time the checkpoint was last written. The orphan sweep deletes document checkpoints older than its cutoff that have no
documentsrow.
Keys and constraints
- Primary key
(app_kind, local_id)
DDL
The statements the client runs to create this table and its indexes.
CREATE TABLE IF NOT EXISTS "document_history_checkpoints" (
"app_kind" TEXT NOT NULL,
"local_id" TEXT NOT NULL,
"snapshot" TEXT NOT NULL,
"end_version_vector" TEXT NOT NULL,
"revision" TEXT NOT NULL,
"updated_at" TEXT NOT NULL,
PRIMARY KEY ("app_kind", "local_id")
);