Expand description
How a resource’s storage changes between versions of its app.
A record stores the schema version it was written at under one key
(VERSION_KEY, read by stored_version); #[resource(version = N, migrate = path)] declares the current one and how to bring an older
document up to it (rewrite, after its derived steps). A document that does not read as the
model is Unreadable: views show why and actions report it, and stale
state is never shown as current.
Structs§
- Unreadable
- A document that does not read as its resource: what a view shows in place of stale state, and why each action is unavailable.
Constants§
- VERSION_
KEY - The root key a document’s schema version is stored under, when it is past
the first. Every document keeps it here: an app’s record, a settings
document, a
tilo-docpage.
Functions§
- check_
version - Whether
docholdsRat a version this build reads: its own or an older one, whose chain of steps stops short and is brought up before it opens. A newer version only adds fields and containers to a type, so this build’s fields are all still there and it reads them as far as it knows the record. - copy_
into - Write what the record
fromholds into the recordto, another record of the same kind and storage version kept elsewhere: what a record moving from one store to another takes along. Every field is copied as it is stored, scalars with their types, maps, lists and texts; the record’s own identity (itstilo:keys other thanVERSION_KEY) staysto’s. A map or texttoalready holds at a key is written into rather than replaced, so what another writer adds to it concurrently is kept. - fixture
- Write the keys of the JSON object
shapeinto the mapobjas an older version of an app stored them: what a migration’s test builds the document it migrates from. An object is a map, an array a list, a string, a boolean and a number are scalars (an integer asInt),nullis a null scalar, and{"$text": "…"}is a text object holding the string. - needs_
migrate - Whether
docis older thanR: its chain of steps stops short ofR’s version, so it is brought up (crate::founding::bring_up) before it is read. - read_
checked - Read
Rfromdoc, or say why it does not read. - rewrite
- The app’s own rewrite of the record
scopenames forversion, from the versionfromit stood at, bymigration(its#[resource(migrate = ..)]): once, as one housekeeping change after the record’s step toversion, made by an actor and at a time derived from the record, its workspace, the version and the heads it starts from, so two holders rewriting the same history make the same change. It is decided as any write of the record’s. A rewrite rewrites by key and never inserts list elements, so two holders rewriting apart converge on one item each. Whether it changed anything. - step
- The step that brings the record
scopenames toversion: the change every holder makes alike, under an actor derived from the record, its workspace and the version alone, at time zero, writing the version key and nothing else.beforeholds exactly the link it follows, the record’s founding for the first version and the step to the version before otherwise, so the chain a record stands on is one every holder derives (crate::founding::chain), however its content went on meanwhile. - stored_
version - The schema version
docwas written at: 1 when it names none. - write_
version - Record that
docis atversion(nothing for the first version, so documents of apps that never changed their storage stay as they are). - write_
version_ at write_versionof the document whose root isat.