projectHistoryChunks holds one document per history chunk, a run of versions in the history of one project. Mongo only holds the chunk’s metadata; the chunk itself (a snapshot plus the changes after it) is a gzipped JSON object in the chunks bucket. There is no Mongoose schema: history-v1 writes the collection in services/history-v1/storage/lib/chunk_store/mongo.js, which it uses for every history id of 24 hex characters, as in CE (services/history-v1/storage/lib/chunk_store/index.js:644-652).
Fields
Who Writes It
New chunks come from project-history, which sends the queued edits to history-v1
POST /projects/:project_id/legacy_changes (services/history-v1/api/routes/project_import.js:29-31); history-v1 then calls chunkStore.update or chunkStore.create (services/history-v1/storage/lib/persist_changes.js:215, 229). A new project gets its first chunk from chunkStore.initializeProject (chunk_store/index.js:54-80).
Who Reads It
Indexes
Notes
- State flow:
pending(record written, upload running) →active(the latest chunk, can still be extended) →closed(a newer chunk follows) ordeleted(replaced, or the project was deleted). Reads only look atactiveandclosed. - The chunk object is gzipped JSON (
services/history-v1/storage/lib/history_store.js:151-170) at the key<project key>/<chunk id>(history_store.js:65-67). The project key is the zero-padded history id, reversed and split as 3/3/rest characters (libraries/object-persistor/src/ProjectKey.js:8-15). The bucket isOVERLEAF_EDITOR_CHUNKS_BUCKET(services/history-v1/config/custom-environment-variables.json:53-56):/buckets/chunksin the dev env (develop/docker-compose.yml:90), oroverleaf-chunkswithS3_ENABLED=true(develop/s3/docker-compose.yml:51). - Records in
deletedorpendingstate, and their bucket objects, are only removed bydelete_old_chunks.js(yarn delete_old_chunks,services/history-v1/package.json:79). The CE image has no cron job for it (server-ce/config/crontab-history,server-ce/config/crontab-deletion), so in CE they stay. - When web expires a deleted project, it calls history-v1
DELETE /projects/:history_id(services/web/app/src/Features/Project/ProjectDeleter.mjs:385-391,HistoryManager.mjs:127-135,152-162), which marks all of the project’s chunksdeleted. - With a
backupStoreconfigured, confirming a chunk also writesoverleaf.history.currentEndVersion,currentEndTimestamp,updatedAtandoverleaf.backup.pendingChangeAtto the project (mongo.js:232-262). CE does not configurebackupStore, somongo.js:238-240returns early.

