Cross-version upgrade and migration strategy
Migrations are recorded by module plus version number, and once used a number belongs to that migration; failure rolls back together with the store and downgrades are refused by default; the old store meeting the new binary is verified by a dedicated drill chain.
The hard part of an upgrade is not "swap in a new binary"; it is that the new binary must run correctly on the old store. This page says clearly how versions are managed, how migrations are recorded, what happens on failure, and how we verify.
Migrations are recorded by "module + version number"
Each module declares its own migration sequence, and the system records which have run by (module, version number). Editing the body of an already-applied migration does not re-run it — the version number did not change, and the system considers it already executed.
Two hard rules follow from this:
Once a version number is used, it belongs to that migration. To add something an old store lacks, you can only write a new number, and it must be higher than the largest number that old chain has used. Moving an already-used number to describe another migration: that number was recorded in the old store long ago, and the new code will never run — what is missing is not an error, it is missing structure: not one table missing, all interfaces return 200, and certain manifest surfaces return 500 on the spot.
Backfill migrations are forward additions, not reordering rollbacks. The right shape for fixing an old store is "add a new migration it has never run", not renumbering the old migration.
A misused version is detectable
The system compares each migration's declared name with the name recorded in the ledger; on a mismatch this tier is reported as pending (not failed): the site is still serving at that moment, and treating it as fatal would report a usable state as "release failed".
Why it is worth reporting separately: that version in the old store has already run and the new code will never execute it, so what this change did never takes effect, while the probe stays all green. This alert is currently the only thing that can say whether something "made it into the store".
Two opposite mirrors pin it down: no reporting when the name did not change; no reporting when the ledger row never recorded a name (this column is empty in old stores) — otherwise every row goes red after the upgrade, and the consequence of noise is not one extra alert; it is that nobody trusts it anymore.
What happens on failure
The upgrade script stops the service first, then backs up the binary and database (including the WAL sidecar file), then swaps files, writes the unit, starts the service and probes the health endpoint. Any step failing midway rolls back together with the database, including a step like "install files" that looks like it cannot fail (disk full, permissions, artifact missing files).
Downgrades are refused by default, because migrations are not backward compatible. For a real rollback use the dedicated flag; it is for rolling back, not for "I want to install an old version".
The reinstall scenario (the only upgrade path on an old environment) also rolls back: it takes the database backup after shutdown, before swapping files, and does not disable the service unit — before you came to install it was already serving, and disabling would mean after a failure even the original copy no longer serves.
The order of rollback actions also matters: first move away the current store files, then copy the backup; do not overwrite in place. The backup was taken after shutdown and has no WAL; overwriting only the main file would let the WAL left by the failed version "recover" the old store into the new structure — the rollback reports success while the migration and the writes both come back.
How to verify: use the old store, not a new one
Every module's migration tests run on stores they created themselves, and such stores are always structurally complete. So there is an independent upgrade drill chain: build a store from the old version's source, initialize, seed content, then hand the entire data directory as-is to the current binary, and go through asking whether each backend manifest surface answers, whether content counts and public pages match.
One reading on this chain must be stated honestly: on an upgraded old store, migrations: pending is the normal shape (the ledger has rows of a new version nobody has claimed), neither "upgrade failed" nor "no problem". Treating it as fatal is a false alarm; ignoring it misses the version that really did not get in.
Version numbers and releases
The version number has only one owner: the single constant in the kernel. The release order is first settle the new version and commit clean source → package and accept → keep the complete signed artifact and its corresponding source commit → tag that commit. A version already tagged must not be repackaged; the next official release must use a new number — otherwise "which bytes exactly are running in production" becomes a question of memory again.
The toolchain version requirement is a real constraint, not a preference: the build requires a certain Go patch version or above because below it there are standard-library vulnerabilities reachable from this site's code, and this site's shape is a single process connecting TLS and HTTP/2 directly, with no one else shielding us. Dependency vulnerability scanning is a failure condition in the full gate, not a report.