Expand description
Safe schema upgrade path for vault files.
When tsafe loads a vault whose _schema version is older than the
current one, migrate::run applies transformations in order and writes the
upgraded file back to disk atomically. A snapshot is taken before any
mutation so there is always a rollback point.
Adding a new migration:
- Increment
CURRENT_SCHEMAto the new version string. - Push a new
Migrationentry into theMIGRATIONSslice. - Write a pure
fn(VaultFile) -> SafeResult<VaultFile>that performs the structural change. No I/O inside the transform function.
Constants§
- CURRENT_
SCHEMA - The schema version this build writes.
Functions§
- run
- Check whether
fileneeds upgrading and, if so, apply all pending migrations, write the result back topath, and returntrue. Returnsfalsewhen the schema is already current. ReturnsErrwhen the schema is unknown or a transform fails.