Uh oh!
There was an error while loading. Please reload this page.
docs: document upgrading an existing installation - #786
Merged
Conversation
What triggers an upgrade, how the upgrade key gates the page, how a migration is selected, and what each one does. The part worth writing down is why the text migration runs exactly once: decoding stored text is not idempotent and cannot be made so, since nothing in a value says whether it has already been decoded. What bounds it to a single run is the recorded database version, and the transaction wrapping the file is what keeps an interrupted run from leaving rows half decoded with no version stamped.
blaiprforce-pushed
the
docs/upgrade-guide
branch
from
August 16, 2026 14:10
2d6a2ae to
97e05e8CompareUh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
upgradeappeared in no document, whileschemas/carries two versioned migrations and there are elevenUpgrade*classes. Anyone moving a real installation onto this rewrite had to read the SQL to find out what it would do.What it covers
What triggers an upgrade. Two recorded versions are checked against the running code —
databaseVersionandappVersion— and either being behind diverts the request. Both are read because they answer different questions: stamping only the database version once left an installation that had upgraded successfully being sent back to the upgrade page, with its one-time key already spent.The upgrade key. The page is reachable before anyone signs in, so it is gated by 16 random bytes written into
config.xml, compared withhash_equals()and cleared on success — readable only by someone who already has the database credentials.How a migration is selected, including that
UpgradeDatabasederives its filename from the version, so a version with no matching file is an error rather than a silent no-op.The part worth writing down
The text migration runs exactly once, and cannot be made idempotent. Run twice,
&goes from&to&, and nothing in a value says whether it has already been decoded. What bounds it to one run is the recorded database version.That is why the file is wrapped in a transaction: every statement is DML, so an interrupted run rolls back rather than leaving rows half decoded with no version stamped — the one state no second run could repair.
UpgradeDatabase::apply()has no rollback of its own; what unwinds the work is PDO tearing down the connection.The page also records that the ampersand is decoded last within each value, because somebody who typed
<had it stored as&lt;, and decoding the ampersand first would take that to<and quietly change what they wrote.Counted, not recalled
The migration is described as touching 28 columns across 12 tables. The figure that has been carried around in commentary was 24 across 11 — the table count was short because
CustomFieldDatais updated through a join rather than a plainUPDATE … SET, which is also what excludes encrypted values (isEncrypted = 0). Parsing the file rather than trusting the note is what surfaced both.Verified
The four-hour temporary-password default, the 16-byte upgrade key,
start transactionat line 24 andcommitat line 144, and the two#[UpgradeVersion]attributes onUpgradeDatabasewere each read out of the source. The README table gains a row and stays alphabetical.