Skip to content
Edit this page

Template migrations

Migration files live in migrations/, alongside template.toml in the template repository. They declare messages and content-preserving path moves, never executable steps.

# migrations/2026-08-config-move.toml
message = "The configuration now lives in a module."

[[moves]]
from = "src/config.rs"
to = "src/config/mod.rs"

message is optional and may use the destination rendering context. Alternatively, set message_file to a repository-root-relative path; the two fields are mutually exclusive. The path may be templated, and a file ending in .jinja is rendered before display. An empty rendered message-file path suppresses the message. moves is an optional ordered list of source/destination paths. Move paths are literal rendered-output paths, not files in the template's source tree or path expressions. The linter validates declaration shape; update checks whether a move applies to the previous rendered tree. Moves touching initialized one-shot paths are refused.

Discovery and ordering

There is no separate template version counter or project migration ledger. Update discovers newly introduced migration paths between the previous and resolved template revisions. Files run in path order and moves within a file in declaration order. A direct jump applies newly crossed declarations without rendering each historical intermediate revision.

Moves may produce a content-identical rename commit before the ordinary rendered commit, preserving Git's ability to recognize the rename during merge. Both commits append to the existing rendered history. See ADR-024.

Messages and failures

Messages are sanitized and displayed as attributed template text, never executed. JSON carries the original message text. An invalid move fails before committing the update. The command's migration recovery guidance covers unavailable historical revisions.

Use migration test cases to test direct jumps, intermediate upgrade boundaries, and preservation of project-local edits.