The entries in the database
tilttek/journal-bundleDbalJournalStore implements Tilttek\Journal\Contract\JournalStoreInterface on a Doctrine DBAL connection, in two
tables that JournalTables describes for each platform and the schema listener adds to the schema the ORM generates.
The tables
tilttek_journal_entry holds one row per entry:
| Column | Holds |
|---|---|
seq | An increasing integer, the primary key: the order the entries were first kept. |
id | The entry's identifier, unique. |
journal, genre, author | What the entry was drafted with; a change never writes them again. |
title, audience, subject, state | What a change writes. |
published_at | The time it was published, in UTC to the microsecond, as 2026-12-01T20:15:03.250000Z; null for a draft. |
version | The version the entry is kept at, 1 once first kept. |
It is indexed by journal and sequence, so that a journal's entries are read in order without a sort, and by author and sequence, for an export or an erasure.
tilttek_journal_block holds the blocks of each entry, the entry and the position their primary key: its identifier,
its text in body, its kind, its audience, its secret, its origin and its source. A text holds up to 20 000 characters
of UTF-8: MySQL and MariaDB keep it in a MEDIUMTEXT, PostgreSQL and SQLite in a TEXT. On MySQL and MariaDB, the
identifiers and the values of the enumerations compare byte by byte, as they do in PHP.
A publication time is read back in UTC: the same instant, in another time zone than the one it was given in.
Writers at once
Every change names the version it was made on. A new entry, at version 0, is inserted; a second one of the same
identifier meets the unique index. A known one is updated where it is still at that version and in the same journal,
the version compared in the UPDATE itself, and its blocks are deleted and written again in the same transaction. A
writer that finds another version, an identifier taken, a deadlock or a lock held too long by another writer writes
nothing and throws JournalConflict; Journal lets it through, and the application reads the entry again and shows
the writer what changed. A deletion is made at the version too.
Reading
An entry is read in two queries, its row then its blocks; a journal in two, its entries then all their blocks in one
join, whatever their number. On SQLite in memory, an entry of 20 blocks is read in about 0.14 ms, a journal of 1 000
such entries in 160 to 220 ms — most of it spent by Block reading the mentions of each text again — and a change of
an entry of 20 blocks is saved in about 0.3 ms.
The store keeps nothing between two calls: one instance serves every request of a worker.
Beyond the contract
Two methods serve the privacy module, and an application may call them too:
authoredBy($author, $after, $limit)gives a page of the entries the author wrote, in every journal, by sequence;eraseAuthor($author, $pseudonym)erases what the author wrote, as Privacy describes, and returns the entries erased.