Expand description
Migration file parsing, ID computation, and chain validation.
Every migration file has a two-line header: – migration: m2<38-hex> – onto: m2<38-hex> | initial
The migration ID is m2 + 19 bytes (38 hex chars) of a SHA-256 over the
body and the migration’s position in the chain (onto, plus any
squashed IDs). The short ID used in filenames is the same digest cut to 6
bytes (12 hex chars). m1 — a body-only hash with a 3-byte short form —
is still accepted for files already on disk; see verify_integrity.
Structs§
- Migration
File - A parsed migration file.
Enums§
Functions§
- blank_
body - Generate the stub body for a blank migration (§8.5). Includes the leading blank line that separates the header from SQL content.
- chain_
tip - Return the tip migration ID from an ordered chain, or
"initial"if empty. - compute_
id - Compute the full migration ID (§5):
m2+ 38 hex chars of the digest. - compute_
short_ id - Compute the short migration ID used as the filename component.
- parse
- Parse a migration file’s content.
filenameis used for error messages. - parse_
steps - Split a migration body on
-- pylon:stepmarkers into(transactional, sql)pairs, in order. A step is transactional unless its preceding marker was-- pylon:step non-transactional(that marker applies to the step it introduces, not the one it ends — matching the Python implementation this replaces exactly, including the leading segment before any marker always being transactional). - render_
file - Build the full file content for a migration given
ontoandbody. - split_
statements - Split one step’s SQL into individual statements on top-level
;. - validate_
chain - Validate that
migrationsform a single unbroken linear chain (§6). - verify_
integrity - Re-hash a migration and verify it matches the ID in the header (§9.2).