Expand description
The metadata store on disk: one SQLite file, plm.sqlite, in WAL mode.
§Shape
Each kind of record has its own table. The columns the store queries or
constrains on are real columns (a part’s number, a revision’s label, a
use’s child part, an MPN), and the rest of the record is a JSON body
column. That keeps every field the model has without a column per field,
and a field a later slice adds needs no schema change: it rides in body.
A record’s children live in their own tables, not in its body:
| table | one row per | constrained / indexed on |
|---|---|---|
parts | part | ord (creation order, also the FTS rowid), id, number_lc UNIQUE, category_lc |
revisions | revision | (part_id, label_lc) UNIQUE |
uses | line of a revision’s uses list | child_part, child_revision |
manufacturer_parts | MPN on a part | manufacturer, mpn_lc |
supplier_offers | offer under an MPN | supplier, spn_lc |
part_tags | tag on a part | tag_lc |
users, sessions, api_tokens, part_types, categories, manufacturers, suppliers | record | their ids |
workspace | workspace folder, link or file | (owner, parent), ord |
changes | document key in the change log | seq |
preferences | one reserved key of one user (crate::api::preferences), not in the in-memory state | (user_id, key), (user_id, version) |
audit | audit event | at, the actor, kind, entity_id, part_id, action |
meta | the sequence, the settings, and any state field with no table | key |
parts_fts | part (FTS5, trigram, contentless) | number, name, description, category, tags, attribute values, MPNs, SPNs |
Documents are NOT here: they stay one file each under models/, as the CAD
app writes them.
§Reads
The server still answers reads from the whole state held in memory
(crate::db::Db::read), which this file loads at start-up. What SQL
adds on the read side is the search index and the audit log’s indexed
queries, through a second connection so a search never waits on a write.
§Versions
PRAGMA user_version identifies the current schema. Existing files must
match it exactly; new files are initialized directly without upgrade paths.
Structs§
- Candidates
- The indexed narrowing of a parts search (
Sql::candidates). - Change
- What one committed change moved, for
Sql::write. - Preference
Row - One row of a user’s preferences, without its value.
- Sql
- The SQLite store: a writer connection used under the store’s write lock, a reader for searches and audit queries, and a checkpointer thread.
Enums§
- Durability
- How long a commit waits for the disk.
Functions§
- is_
constraint - Whether
erroris a UNIQUE (or other) constraint the schema enforces — a rule the store’s own checks should have refused first. - schema_
version - The only schema version this build reads and writes.
- small_
value - The state as JSON without its parts, workspaces, sessions or jobs: every other field, whatever it is. Those lists are swapped out for the length of the serialization, so they are never serialized (they are what grows); each has its own journal and table.