Documentation
¶
Overview ¶
Package migrate applies versioned upgrades to ctm's JSON state files.
Each ctm-owned state file (config.json, sessions.json) carries a "schema_version" integer at its top level. On startup, ctm runs a Plan against each file: if the file is below the current version, it applies the pending Steps in order, stamps the new version, and atomically writes the result. The original bytes are saved to a timestamped sibling (".bak.<unix-nano>") before any destructive write so downgrade/recovery remains possible.
The runner is intentionally conservative:
- It never creates a missing file (the owning package decides lifecycle).
- It preserves the existing file mode on write.
- It refuses to touch a file whose schema_version exceeds the current target, so an older ctm binary won't silently mangle state written by a newer binary (downgrade guard).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plan ¶
Plan describes the target version and the Steps to reach it from v0. len(Steps) must equal CurrentVersion: Steps[i] migrates vi → v(i+1).
type Result ¶
Result records what Run observed and did.
Before: the schema_version read from the file. -1 means the file did not exist. 0 means the file existed but lacked a schema_version key. After: the schema_version written. -1 when no write occurred (either because the file was absent or because it was already at CurrentVersion). Backup: path to the pre-migration backup, or "" when none was written.