Upgrade Floors After 1.0: Retiring Pre-1.0 Migration Code Without Stranding Users or Corrupting Data
Executive Summary
A self-hosted agent platform has just reached 1.0. Its data lives on users' own machines: a few SQLite databases, config files and state under a per-user data directory, upgraded in place by a command-line upgrade command. Years of pre-1.0 migrations and compatibility shims are still in the code. The plan is that the next minor release deletes them and declares that upgrades are accepted only from 1.0.0 or later. The question is how to do that without leaving people on old versions with no way forward, and without a half-migrated data directory that nobody can explain.
The main findings:
- Django and GitLab, the two projects here that document how old migrations get removed, put a release boundary between shipping the replacement and deleting the old code. Neither deletes in the release that replaces. Of the two, only GitLab also ships a refusal (its package refuses installed versions below a minimum, section 2.4); Django relies on users upgrading in order. Django's documented process is to squash, keep the old files, release, wait until every system has upgraded (or, for third parties, make users upgrade in order without skipping), and only then remove the old files in a second release. GitLab removes old migrations only up to a planned required stop that it announces at least two milestones ahead. Rails, by contrast, has no refusal: it treats the schema file as the authoritative source and says this "makes it possible to delete or prune old migration files".
- An upgrade floor is a promise about a path, not just a number. Nextcloud, Sentry self-hosted and GitLab publish the intermediate versions you must pass through. Kubernetes' version skew policy requires
kube-apiservernot to skip minor versions. PostgreSQL'spg_upgradestates a supported source range ("9.2.X and later") and has a--checkmode documented as not changing any data. A floor with no documented stepping stone is a dead end for the user who is below it. - Deleting is easy; proving nothing still needs the deleted code is the work. GitLab's guidance names the risk of removing a migration: "Dependent migrations might fail, or the application might not function, because a required migration was removed." Its separate page on existing migrations says they cannot be deleted and may only be disabled (turned into a no-op) under listed prerequisites, one of which is that the migration changes data only, not the schema. Synapse documented a case where a migration bug only hit installs that skipped a release, which is the shape of risk a floor creates when it is set too low.
- Detect the data's version from the data, not from the installed package. SQLite offers
PRAGMA user_version, "an integer that is available to applications to use however they want" that SQLite itself never touches. A package version tells you what code is installed; a stamp written at the end of a successful upgrade tells you what the data has actually been through. The two disagree exactly in the failure cases that matter. - Keep a very small amount of legacy forever: the version check, the refusal message, and a read-only classifier for data too old (or too unclear) to upgrade. Delete other legacy code only when a checkable fact about the data allows it: no data directory the floor accepts, including ones carried up from older releases, can still contain what that code handles. An example from a public desktop app shows why the classifier must outlive the converter: after a converter was removed, the work shifted to deciding safely what to do with profiles that look partly converted.
- Test the floor with real floor-version data directories, including one that came up from an older release through the stepping stone and still holds old-format values, and test that a refusal leaves user data unchanged. Unchanged needs care with SQLite: in my probes, merely opening a WAL-mode database read-only created a
-shmfile next to it, and a missing or damaged-walproduced a staleuser_versionwith no error. Stopping a running service checkpoints its database, which changes the main file's bytes but not its contents, so a refusal can promise identical bytes only if the services were already stopped; otherwise it promises identical logical contents. Also compare a fresh install with floor-plus-migrations; GitLab's squash of pre-2019 migrations was validated by diffing the schema output and found one real difference (a renamed constraint). - Without central telemetry you will not know who is below the floor. The honest answer is to make the refusal self-explanatory and cheap to recover from, to warn in the release before the floor moves, and to treat any counting method (per-version package download counts, an opt-in ping) as a weak signal.
A note on evidence: every URL in Sources was fetched, and every passage in quotation marks was checked word for word against the fetched page or file. Gaps are listed in section 8. Design recommendations in sections 3 to 6 are my own reasoning from these sources, and I label inference as such. The only things I ran were small SQLite probes (SQLite 3.45.1 and 3.53.4) on how a version read and a transaction behave, reported in sections 3.1, 3.2 and 5.1; no product upgrade, migration or floor check was run for this article.
Companion article: When the Database Is Ahead of the Binary covers the opposite direction (new data, old binary, rollback windows). This article covers old data, new binary, and what you may delete.
1. The situation, stated generally
Before 1.0, a product moves quickly. Each release may rename a column, reshape a JSON state file, move a directory, or fix data that an earlier release wrote wrongly. Each change leaves behind either a numbered migration or an ad hoc if (legacy) { ... } branch. After 1.0 the team wants to stop paying for that:
- The code is read, reviewed and kept compiling for a population that mostly no longer exists.
- Old migrations depend on code that kept evolving, so they quietly stop working (more on this below, from both Django's and Rails' documentation).
- A fresh install runs the whole history, which is slow and fragile.
- Tests for ancient states are expensive to keep alive.
The tension is that on a self-hosted product the team cannot see the population. A hosted service can check its own database and delete the migration once every instance is past it. A product installed on many private machines cannot. That is why the prior art below is mostly from self-hosted or distributed software, where the maintainers had to replace we checked with we required.
There are three separate decisions, and conflating them is the usual mistake:
- Floor policy: which source versions will
upgradeaccept? - Enforcement: how does the product refuse, and when (before or after it changes anything)?
- Deletion: which code and tests become removable once the floor is enforced, and which must stay?
2. Prior art: how established projects do it
2.1 Django: squash, keep, wait, then remove
Django's migration documentation describes squashing as "reducing an existing set of many migrations down to one (or sometimes a few)". The squashed migration carries a replaces list, so it "can coexist with the old migration files" and Django "will intelligently switch between them depending where you are in the history": a database part-way through the old set keeps using the old files until it reaches the end, "while new installs will use the new squashed migration and skip all the old ones".
The part most relevant here is what the docs call "The recommended process": squash while keeping the old files, and release that; wait until every system has upgraded to that release (a third-party project should instead make sure its users "upgrade releases in order without skipping any"); only then remove the old files in a second release. The final transition has three steps: delete the replaced files, repoint dependent migrations at the squashed one, and remove the replaces attribute. After that, migrate --prune removes the stale rows from the django_migrations table.
Three other details matter for a floor:
- Squashing can fail. The docs say it "may result in migrations that do not run", and that
RunSQL/RunPythonoperations cannot be optimized through unless markedelidable. Data-migration steps are where squashing is hardest. (Thesquashmigrationsreference mentions astart_migration_nameargument "to mitigate the squashing limitation" of those operations.) - Migrations that reach for live application code rot. Django warns that if you import models directly instead of using historical models, "your migrations may work initially but will fail in the future when you try to rerun old migrations (commonly, when you set up a new installation and run through all the migrations to set up the database)". Functions, custom fields and base classes referenced by migrations "will need to be kept around for as long as there is a migration referencing them".
- Django's own conditions for removal are about knowledge of the population: "all systems are upgraded", or users "upgrade releases in order without skipping any". A floor is the mechanism that turns the second condition into something enforceable.
2.2 Rails: the schema file is the source of truth
The Rails migrations guide is blunt: "Migrations, mighty as they may be, are not the authoritative source for your database schema. Your database remains the source of truth." It says loading the schema file is "faster and less error prone" than replaying the full history, and gives the reason replay breaks: old migrations "may fail to apply correctly if those migrations use changing external dependencies" or "rely on application code which evolves separately from your migrations".
On old migrations it says the schema file "is a snapshot of the current state of your database and is the authoritative source for rebuilding that database", which "makes it possible to delete or prune old migration files". Deleted migrations that had already run show up as NO FILE in the status output. Rails also warns that db:migrate:reset (replaying everything) "can lead to schema drift", whereas db:reset uses the schema file only. Note what Rails does not give you: it does not refuse an upgrade from a database that is too old. It simply stops being able to replay history it has deleted. The refusal, if you want one, is yours to build.
2.3 Flyway: baseline migrations
Flyway's baseline migrations are the cleanest statement that fresh installs and existing installs take different paths. In the Flyway tutorial, a baseline is "a single, cumulative migration that represents the state of your database". It has a B prefix and behaves as follows: "In existing deployments they have no effect as your database is already where it needs to be." For a new database, "the baseline migration with the latest version is applied first", and "Migrations with a version less than or equal to the latest baseline migration's version are ignored". Repeatable migrations still run.
The separate Flyway page on baselines adds two cautions: "Flyway will not baseline over an existing schema history table", and for a database that already exists you must record a baseline version before migrations can run. Flyway's baselineOnMigrate setting is documented as removing "the safety net that ensures Flyway does not migrate the wrong database in case of a configuration mistake". The analogy for a floor is direct: a baseline is a claim that everything up to a point has already happened, and it should be recorded explicitly, not inferred.
I opened Flyway's documentation for these points but not its source code, so how the tool resolves an existing database with migration history older than the baseline is described only as the tutorial states it.
2.4 GitLab: required stops, squash up to the stop, no deletion in place
GitLab is the most explicit source for the full lifecycle, and its developer documentation is public. Three kinds of evidence need to be kept apart here: what the documentation sets as policy, what the shipped code enforces, and what individual cleanup issues did.
Documented policy:
- Required stops. A required stop is a version "you must upgrade to before upgrading to later versions". Between stops the procedure says to "Allow the background migrations for the upgrade to finish". From 17.5 onward stops fall on fixed milestones (
x.2,x.5,x.8,x.11), and the docs advise going to "the latest available patch release" of the stop, not the first one. - Why they exist. In the developer guide, most stops come from "assumptions about the state of the data model in a given release"; in backwards-compatible designs, "the contract phase will likely introduce a required stop"; and they also arise from the "intentional removal of code implemented to workaround previously discovered issues". That last cause is exactly what a post-1.0 cleanup is.
- Cost. "Wherever possible, a required stop should be avoided." The guide says users may trail the newest release by as much as three years and still expect a supported path, and that "Past required stops have not been discovered for months after their introduction".
- Notice. "We give at least two milestones of notice when we schedule a required upgrade stop."
- Checklist. Update the upgrade-path documentation and
upgrade_path.yml, which is "the single source of truth (SSoT) for all our required stops", in the same change; inform Support and release management; open an issue to "squash migrations to that version in the next release", with deliverables that the migrations are squashed and that theGitlab::Database::MIN_SCHEMA_VERSIONconstant matches the init schema version; and in the release after the stop, update the upgrade check hook in the charts project to the stop version. Squashing happens after the stop has shipped, not in it. - Removal rule. The required-stops page gives the risk of removing a migration as "Dependent migrations might fail, or the application might not function, because a required migration was removed." and the mitigation as "Ensure migrations are only removed after they've been a part of a planned required stop." Separately, the "Delete existing migrations" page says a migration that may already have run cannot be deleted, because that could lead to "Schema inconsistency, as changes introduced into the database were not rolled back properly." and to "Leaving a record on the
schema_versionstable that points to a migration that no longer exists in the codebase." It allows disabling instead and lists three prerequisites: the migration caused a timeout or general issue on GitLab.com; it is obsolete, for example because of a feature change; it is a data migration only, one that does not change the schema. The page does not say whether all three must hold, but its procedure is headed "How to disable a data migration?". Disabling means emptying the#up,#downor#performmethods, leaving a no-op comment and a comment explaining why, with a database maintainer's approval. So the no-op route is for data-only migrations; it is not a general licence to switch off any old migration.
Implementation, in the code I read:
- Package install refuses before files are replaced. The Omnibus package's pre-install script (
preinst) runs on an upgrade, before the new package's files are installed. It reads the installed package version fromversion-manifest.json, compares its major.minor with a hard-codedMIN_VERSION(19.5 in the version I read), and if the installed version is lower it prints that the user must first upgrade to the latest19.5.x, points to the upgrade documentation, and exits with status 1. Only after that check (and a configuration and PostgreSQL version check) does it take its automatic database backup. Note what this compares: the installed package version, not a version stamp in the data. The charts project has its own upgrade check hook, and theMIN_SCHEMA_VERSIONconstant above is a third, database-side value. I did not read how the application uses that constant.
Individual cases:
- Cleanup issues. Issue 370640 set out to remove pre-15.0 migrations, with a deliverable that all background migrations from before 15.0 are finalized. Issue 409574 refers back to it ("we removed all of the pre-15.0 database migrations since that was a required stop") and repeated the cleanup for pre-16.3 migrations, with deliverables that included finalizing all background migrations from before that version.
- A squash validated by diffing. An older merge request squashed all pre-2019 migrations into a single init-schema migration, justified by "we require GitLab major upgrades to go from one major to the next major version at a time". Its author did not trust a squash tool; they migrated an empty database to that version, dumped the schema, used the dump as the new initial migration, and compared schema output from the branch and from main. The comparison "yields no differences", and the SQL dump showed one: a renamed foreign key constraint.
What GitLab's pages do not say, in what I read: what happens technically if a user skips a stop (the upgrade-paths page lists the sequence but states no consequence; the preinst check above is the only refusal I read, and it checks a single minimum). The developer guide does mention that skipping a stop can force a migration to run synchronously, "causing downtime if the migration runtime exceeds the maintenance window".
2.5 Sentry self-hosted: hard stops for people who upgrade rarely
Sentry's self-hosted documentation lists "hard stops" (for example 9.1.2, 21.5.0, 23.6.2, 23.11.0, 24.8.0 and later ones) and says "When upgrading one must upgrade to each hard stop to pick up significant database changes." It also warns: "If you upgrade infrequently, it's less likely that upgrading to the latest version will work." The example path from 22.8.0 to 24.2.0 is 22.8.0 -> 23.6.2 -> 23.11.0 -> 24.2.0, each step being git checkout <version>, ./install.sh, then start the stack. It also lists specific versions to avoid because of migration errors and InconsistentMigrationHistory problems. That last list is a useful reminder: stepping stones need maintenance as well, and a stone that is itself broken is worse than none.
This is documented policy: a required path. The page does not say whether, or how, the install script detects the version being upgraded from and refuses to skip a hard stop, and I did not read the script, so I cannot report how (or whether) Sentry enforces the stops technically. The page also gives no figures on how often users skip versions.
2.6 Nextcloud: no skipping majors, no downgrades, enforced by the server code
Documented policy: Nextcloud's admin manual says "You cannot skip major releases", tells admins to upgrade to the latest point release of the current major first, and gives a path example 18.0.5 -> 18.0.11 -> 19.0.5 -> 20.0.2. It also says "Downgrading is not supported and risks corrupting your data!" and recommends a fresh install plus restore from backup to go back.
Implementation, in the code I read:
- The server refuses cross-major upgrades. In the server repository,
lib/private/Updater.phpreads the installed version from the instance's configuration (theversionsystem value, whichdoUpgrade()writes only at its very end, under the comment "only set the final version if everything went well"; it is a completion stamp, not the version of the code files present), anddoUpgrade()begins by checking it against the list of allowed previous versions shipped with the new code ($OC_VersionCanBeUpgradedFrominversion.php). If the check fails it throws "Updates between multiple major versions and downgrades are unsupported." This runs after the new code is in place. It also runs afterupgrade()has already switched on maintenance mode and set the log level to debug in the configuration; on failure the log level is restored and maintenance mode is left on. So the refusal leaves the user's data alone, but not every byte of configuration. - The separate web updater has a guard against installing a lower version over a higher one (
version_compare(...) '<'throws "Downloaded version is lower than installed version"), and it can be told by the update server's response that automatic update is disabled for a release ("The updater is disabled for this update - please update manually").
The second point shows a design option: let a small manifest outside the binary influence the allowed next step, so that the rule can be changed without shipping new client code. I did not establish how the update server decides which version to offer a given instance (section 8).
2.7 Synapse: compatibility stamps, and a skipped-release bug
Synapse stores a "compatibility version" in the database. The docs define it as the schema version "of the oldest version of Synapse which will work with the database", and say: "On startup, if compat_version is found to be newer than SCHEMA_VERSION, Synapse will refuse to start." This is the rollback direction, covered in the companion article, but it shows the idea of stamping the data with what it needs.
On the old-data direction, Synapse's upgrade notes take a looser line than the others: you must read the notes for each version between yours and the latest, but "you do not need to perform an upgrade to each individual version that was missed", although "we recommend that you upgrade through each incompatible database schema version" because that "would give you the ability to roll back the maximum number of versions should anything go wrong". It explicitly says "We do not have a list of which versions must be installed". Its schema documentation keeps full-schema snapshots for fresh installs ("only the most recently-numbered snapshot is used").
The upgrade notes also include a real example of what a floor protects against. A bug introduced in 1.4.0 "could cause the room directory to be incomplete or empty if Synapse was upgraded directly from v1.2.1 or earlier, to versions between v1.4.0 and v1.12.x". Installs created at 1.4.0 or later, upgraded via 1.3.x, or upgraded straight to 1.13.0 or later were fine; the notes provide a SQL repair. That is a migration that was correct for the common path and wrong for one skipping path, found afterwards. A floor does not remove that risk; it moves it to the line you draw.
2.8 Kubernetes and PostgreSQL: floors expressed as supported ranges
These two are not self-hosted-app migrations, but they show how to word the rule.
- Kubernetes. The version skew policy says "Project policies for API deprecation and API change guidelines require
kube-apiserverto not skip minor versions when upgrading, even in single-instance clusters." It also defines supported skew for other components and says the project maintains release branches for the three most recent minor versions. The lesson for wording is that which versions may talk to each other and which versions may upgrade to which are two policies; the page also notes that deployment tools "may place additional restrictions". - PostgreSQL.
pg_upgrade"supports upgrades from 9.2.X and later to the current major release". Its--checkoption is described as "check clusters only, don't change any data". Its "Reverting to old cluster" section is a good model for a refusal's rollback story: if--checkwas used, or neither--linknor--swap, "the old cluster was unmodified; it can be restarted"; with--link, once the new cluster has been started "it has written to shared files and it is unsafe to use the old cluster", and the old cluster must be restored from backup; with--swap, the old cluster is unmodified only if the tool stopped before reporting that the old cluster is no longer safe to start. The promise is about the old cluster's data, not about every file on disk: the same page sayspg_upgrade"launches short-lived postmasters in the old and new data directories" and keeps working files such as schema dumps in apg_upgrade_output.ddirectory under the new cluster. That is a documentation pattern worth copying: state exactly what stays unchanged, and at which step the old data stops being safe to reuse.
2.9 SQLite: PRAGMA user_version
SQLite documents user_version as an integer at offset 60 in the database header, "available to applications to use however they want. SQLite makes no use of the user-version itself." It is a first-class place to stamp an application's schema level in each database file. application_id identifies a file format to tools such as file(1). By contrast, schema_version is SQLite's own counter and the docs warn that setting it "can lead to incorrect answers and/or database corruption". I did not find, in the pages I read, any guidance on using user_version for migration floors, so the application of it below is my own. One caveat for WAL-mode databases: until a checkpoint copies them into the main file, committed changes, including a new user_version, live in the separate -wal file, so the header bytes of the main file can be stale; section 3.2 covers how to read the value without writing.
2.10 A public example of the classifier outliving the converter
A recent pull request in Cherry Studio, an Electron desktop app with local profile data, shows what happens after a legacy converter is deleted (PR #25469). The old v1-to-v2 converter had been removed in an earlier release, but code remained that classifies a profile and, if it looks legacy, blocks startup and offers a pinned older installer as a bridge. The PR changes that read-only classifier so that a profile counts as ready only on positive evidence: a completed migration status, or, when there is no migration status row at all, the runtime's seeding journal entries. Every other non-empty database is classified as recovery: a failed or in_progress status, and a database with committed rows but no status row (the hard-crash case). A recovery profile is offered the old bridge only if both of its old storage directories are still on disk; otherwise the app shows a warning that names the profile path, says the data was left untouched, and quits without writing anything. The PR states the principle behind this: "Clearing a populated database can never be proven safe when the legacy source cannot be located." An automated review approved the change and noted two non-blocking regressions, one being that an interruption during first-launch database initialization can stop a fresh profile from starting. At the time of writing this is an open pull request, not a policy document, so it is evidence of the pattern, not of an outcome.
2.11 Summary
- Django. Floor: a
replacessquash, and third-party users asked to upgrade in order. Old migrations removed in a second release, after systems have upgraded. Notice: the documented process. - Rails. Floor: none built in. Old migration files may be deleted because the schema file is authoritative. Notice: documentation only.
- Flyway. Floor: a baseline version. A
Bbaseline migration is ignored on existing databases. Notice: documentation. - GitLab. Floor: documented required stops; the Omnibus
preinstscript refuses upgrades from an installed package below a minimum version and names the stop; the charts project has its own upgrade check hook; a minimum schema version constant on the database side. Old migrations squashed up to a shipped stop; outside a squash, an existing migration is not deleted, and a data-only one may be disabled under listed prerequisites. Notice: at least two milestones. - Sentry self-hosted. Floor: a documented hard-stop list and example path; enforcement not examined. Old migration removal not examined.
- Nextcloud. Floor: documented no-skipping of majors, enforced in the server's
Updater::doUpgrade()against an allowed-previous-versions list. Old migration removal not examined. Notice: documentation. - Synapse. Floor: a compatibility stamp (rollback direction); upgrade notes do not require each version. Fresh installs use schema snapshots. Notice: upgrade notes.
- PostgreSQL. Floor: a stated supported-from range, plus
--check. Old migration removal: not applicable. Notice: documentation.
3. Design elements for a small self-hosted product
The rest is my reasoning from the sources above, applied to a CLI plus services plus SQLite plus a per-user data directory.
3.1 Two versions, and which one decides
There are two candidates for the version being upgraded from:
- Package version: what
package.jsonof the installed code says. - Data version: what the data directory says it has been through.
They differ whenever an upgrade was interrupted, the package was reinstalled or downgraded by hand, the data directory was restored from a backup, or the data was copied to another machine. The floor must be checked against the data version, because the floor is a statement about what state the data is in. (Nextcloud's server works this way: it compares against a version value it writes only after a successful upgrade. GitLab's Omnibus preinst compares the installed package version instead, which is simpler but answers a different question.) Practical shape:
- One small state file in the data directory records the product version that last completed a full upgrade (the completion stamp). Each SQLite database also carries
PRAGMA user_version, set to the number of the last migration applied to it. The state file answers which release's migrations the data has been through;user_versionanswers, per database, whether that database matches the schema the code expects. The state file also lets the code work out whichuser_versioneach database should have, which is what makes the cross-check in 3.2 possible. - An upgrade-in-progress marker names the source and target versions and the backup location. A marker found on the next start means a previous run did not finish; that is the half-migrated case (section 5.1).
- Compare with semver precedence, not string comparison:
1.0.0-rc.1is lower than1.0.0. Decide explicitly whether pre-release data may upgrade; refusing is the safe answer. - If the stamp is missing (data from before the stamp existed), do not guess from the package version. Fall back to a small legacy detector that looks at structure (tables, columns, file names) and returns one of three answers: at least the floor, below the floor, or unknown. Unknown should refuse with a message, not proceed.
The upgrade then writes to disk in one fixed order, under one locking protocol. Every later section (the tests in 3.5, recovery in 5.1) assumes both.
Locking. A lock on the data directory is cooperative: flock(2) places an advisory lock, so it excludes only processes that also ask for it. Every process that opens the data therefore has to take part:
- Each service takes a shared lock on the data directory (
flock(2)on a descriptor of the directory itself, which creates no file) before its startup check, and holds it until its process exits. It never releases the lock between the check and its first write. If it cannot get the shared lock at once, because an upgrade holds the exclusive one, it refuses to start. - The startup check passes only if there is no upgrade marker and the data version is exactly the one this binary uses directly. Being at or above the floor only means the data can be upgraded; a service must not run on such data before the upgrade has run.
upgradetakes the exclusive lock (step 2), which it cannot get while any service holds a shared lock. In my probe (Python'sfcntl.flockon Linux, separate processes), while one process held a shared lock on the directory, a non-blocking exclusive request failed at once withEWOULDBLOCKand another shared request succeeded; while a process held the exclusive lock, a shared request failed the same way; no file was created. A service that forks workers must make sure they hold or inherit the lock correctly; I did not probe child processes.
- Stop the services and wait until their processes have exited. A clean shutdown of the last SQLite connection checkpoints the database and deletes its
-waland-shmfiles (stated in SQLite's WAL documentation, and seen in my probe). This step already changes bytes: the checkpoint rewrites the main database file, though not its logical contents. Section 3.2 covers what a refusal can therefore promise. - Take the exclusive lock without waiting. If a service still holds its shared lock (a supervisor restarted it, or a worker survived), refuse and say which. A second
upgradethat cannot get the lock refuses the same way. Neither refusal changes anything beyond what step 1 did. - Read and classify the data version without writing (3.2). Below the floor, unknown, unreadable, or a marker that 5.1 does not accept: refuse here.
- Finish a recoverable backup of the whole data directory to a location outside it, flushed to disk, and check it (for example, open each copied database and run
PRAGMA quick_check). Nothing in the data directory has changed since step 1. GitLab'spreinsthas the same shape: version check first, then the automatic database backup. - Persist the marker: write a temporary file,
fsyncit, rename it into place, thenfsyncthe data directory. Rename makes the replacement atomic for readers, but on Linux it is not by itself a promise that survives power loss: thefsync(2)manual says that callingfsync()on a file "does not necessarily ensure that the entry in the directory containing the file has also reached disk", and that "an explicit fsync() on a file descriptor for the directory is also needed". - Commit each database, then each file. Each database's migrations and its new
user_versiongo in one transaction on that database, so either both are committed or neither. A SQLite transaction protects one database only: SQLite's ATTACH documentation says that in WAL mode, if the computer crashes during a COMMIT that updates two or more database files, "some of those files might get the changes where others might not". (AROLLBACKdid restore schema anduser_versionin both of two attached databases in my probe, but that is not a crash.) Each database runs this phase withPRAGMA synchronous=FULL: SQLite's pragma documentation says FULL "is atomic, consistent, isolated, and durable (ACID) in WAL mode", and warns that "A transaction committed in WAL mode with synchronous=NORMAL might roll back following a power loss or system crash." Thefsynccalls on the marker and stamp do not sync SQLite's WAL; only SQLite's own setting does. Files are rewritten with the same temp-file,fsync, rename, directory-fsyncsequence as the marker. Every step in this phase must be able to tell from the data itself whether it has already been done, and skip itself if so: a migration checks the database'suser_versionbefore running, and a file rewrite recognizes a file already in the new form. Recovery in 5.1 depends on this. - Write the completion stamp (the state file) with the same sequence.
- Clear the marker: delete it and
fsyncthe directory. Then release the lock and start services.
Trade-off: two stamps can disagree with each other, and the code must say which wins. My inference: the state file is authoritative for which upgrades the data directory has completed, and a user_version that disagrees with it is an error that stops startup, not something to repair silently. The one designed exception is recovery from an interrupted run (5.1), where the marker says that an upgrade from a named source to a named target was under way.
3.2 Where the refusal runs
Order matters more than anything else on the refusal path. From the prior art, the strongest property is that a refusal leaves the user's data unchanged: pg_upgrade --check is documented as not changing any data, while still starting temporary server processes and creating working files (2.8). For a CLI that replaces its own code, I see three layers:
- Pre-install check in the old CLI, from target metadata. Before replacing any code, the running CLI reads the target release's declared upgrade-from floor (for example a field in the published package metadata or a small manifest) and compares it to the data version. This protects users who run an old CLI that already understands floors. It only works for CLI versions that shipped this code, which is why the release before the floor moves matters (section 3.7). I have not verified whether the package manager used for distribution exposes such a field cheaply; that is an implementation detail to check. GitLab's
preinst(2.4) is this layer in a system package, though it compares package versions. - Pre-mutation check in the new code. Whatever replaces the code must, before touching data, read the data version and refuse if it is below the floor (step 3 of the order in 3.1). This catches users whose old CLI cannot do layer 1. The new code is already installed at this point, as with Nextcloud's server-side check (2.6), so the refusal message must say how to put the old code back, not just that the upgrade failed.
- Startup guard in every service. If services start on new code against below-floor data (for example after a manual package update followed by a restart), they must refuse to run rather than try. This is the startup check from the locking protocol in 3.1: shared lock held, no marker, and the data at exactly the version this binary uses. PM2 services that crash-loop on refusal are noisy but safe; a clear single log line and a non-restarting exit status is better (a design choice with a trade-off: a service that stays down silently is a different failure).
Reading the version without writing. With SQLite in WAL mode this is less obvious than it sounds. I ran a small probe (SQLite 3.45.1 through Python and 3.53.4 through Node.js, same results) on a WAL-mode database whose newest user_version was committed to the -wal file but not yet checkpointed:
- Opening the database directly with a read-only connection read the correct value, but created a
-shmfile next to the database. This matches SQLite's documentation, which says a read-only WAL database can be read if the-shmand-walfiles already exist, if the directory is writable so they "can be created", or if the connection uses theimmutableparameter. With the directory made read-only, the open failed instead. - With
immutable=1, no file was created, but SQLite ignored the-waland returned the stale value from the main file. The main file's header bytes are stale in the same way. - With the
-walmissing (as in a copy that left it behind), or with its header damaged, a read-only open returned the older value with no error at all, and created new files beside the database. - Copying the database and its
-wal(if present) into a scratch directory outside the data directory and opening the copy returned the correct value, and left the data directory's file list and bytes unchanged.
So the read path I would use is the last one: after stopping the services and taking the lock (3.1), copy each database plus any -wal to a scratch directory and read user_version there. After a clean shutdown there is normally no -wal, and the copy is just the database file. Because SQLite itself cannot tell a lost or damaged -wal from a clean one, reliability has to come from the cross-check: if any database's user_version differs from the value the state file implies, classify the data as unknown and refuse. A failed copy or open is also a refusal, with the error in the message. (A lost -wal whose lost part did not include the user_version change is ordinary data loss that no version check can see; the backup in 3.1 is the defence there.) Opening the original read-only and accepting a new -shm is a possible alternative, but then the promise has to be narrowed to existing files being byte-identical, and the refusal test in 3.5 has to allow for the extra file.
What a refusal can promise depends on whether upgrade had to stop running services. If the services were already stopped, a refusal at steps 2 or 3 of 3.1 leaves every file in the data directory byte-identical. If upgrade stopped them in step 1, the shutdown checkpoint has already rewritten main database files, so the promise is about logical contents instead: each database has the same user_version, schema and rows, and every other file has the same bytes. A product that wants identical bytes in every case would have to refuse before stopping the services, which means reading the version while they still write; that brings back the WAL read problem above. I would accept the logical promise, state it in the docs and test both cases (3.5).
The message itself should be mechanical and specific: current data version, required minimum, the exact stepping-stone version to install first, the exact command to install it, and what that step will do. It must also say which of two states the user is in, because they differ: the user's data is unchanged in both, but after a layer-1 refusal the old program is still installed, while after a layer-2 or layer-3 refusal the new package is already installed and cannot use this data, so the user must reinstall the old version (or the stepping stone) before the product runs again. The stepping-stone should be the latest patch of the floor line, as GitLab and Nextcloud advise ("the latest available patch release", "latest point release of your current major version").
3.3 What to keep forever and what to delete
The floor does not describe the oldest code, it describes the oldest data you accept. Data created by pre-1.0 code and carried unchanged through 1.0.x upgrades is floor-version data: two databases can have the same user_version and the same schema while one still holds an old enum value or an old config key and the other does not. So the conditions for deleting code have to be stated as facts about the data that a test can check, not as facts about what the floor release writes.
Keep:
- Version machinery: the data-version read (3.2), semver compare, the floor constant.
- The refusal message and its stepping-stone text.
- A read-only classifier for unstamped or ambiguous data.
- The upgrade-in-progress marker handling (5.1).
- A baseline schema for fresh installs, stamped with the number of the last migration it includes (3.4).
- Every migration after the last one the baseline includes.
- A reader or a repair for every old-format value that floor-version data can still contain, including values written before the floor and never rewritten since. The repair may be a step that runs in the target version and rewrites those values (5.4); then the runtime reader can go, but the repair stays for as long as the floor does.
Delete (after the floor is enforced), each only when its condition holds:
- Per-release migrations that the baseline includes. Condition: the floor fixture's
user_versionis at or above the last of them, so an existing install never runs them, and fresh installs use the baseline. - Shims that translate old config keys, file names or enum values, and compatibility readers for old formats. Condition: no floor-version data directory can contain the old form. That holds only if some release at or below the floor rewrote every occurrence (and that rewrite is part of the path every accepted data directory has been through), or if a repair in the target version rewrites them before anything reads them. Check it with a fixture that came from an older release, not only with one created at the floor (3.5).
- Code that rewrites old data formats. Same condition.
- Repair steps. Condition: the broken state they fix cannot exist in any accepted data directory (5.5).
- Tests for states that can no longer be reached. Condition: the state is excluded by the classifier and the refusal tests cover it.
Choose the floor at the latest release whose migrations or repairs you still depend on, not at the first stable release. If a 1.0.3 patch added a repair migration and 1.0.0 data skips it, a floor of 1.0.0 lets unrepaired data through (this is the Synapse skipped-release shape). Either set the floor at 1.0.3, or keep that repair in 1.1.
3.4 Baseline schema for fresh installs
A fresh install should not replay history. Rails and Flyway both document the schema-snapshot approach; GitLab squashes into an init schema. For SQLite, the equivalent is a single script that creates the schema as the floor release leaves it, stamped with the user_version of the last migration it includes; a fresh install then applies only the migrations after that one. This is how Flyway's tutorial words it: migrations with a version less than or equal to the latest baseline migration's version are ignored.
The boundary needs care. Migrations shipped in the floor release itself, and any seed data (default rows, initial config), must each run exactly once on every path: either they are inside the baseline, or they come after it, never both and never neither. Seed data is the easy one to get wrong, because it is often inserted by code rather than by a numbered migration.
Three conditions make this safe:
- Equivalence: a fresh install must produce the same schema as a floor-version install that migrates to the same target. GitLab's squash was checked by dumping and diffing the schema; the one difference found was a constraint name. For SQLite, compare
sqlite_schematext (normalized for whitespace) plus indexes and triggers; this is a cheap test. - Exactly once at the boundary: on a fresh install, each floor-boundary migration and each seed row appears once (for example, count the seed rows and check the applied-migration record).
- Do not generate the baseline by hand. Create it by running the floor release on an empty directory and dumping the result, as the GitLab author did. Hand-written baselines drift from reality.
Django's squash process offers an alternative if you want to avoid a risky one-shot: ship the baseline alongside the old files for a release, then remove. With a floor enforced in a prior release, you have already waited, so the second release can simply delete.
3.5 Testing the floor
Tests should guard the rules, not every historical state. A proportionate set:
- Real floor fixtures. Two data directories, both produced by real releases, never hand-written: one created by the floor release itself, and one created by an older release (pre-1.0) and then upgraded through the stepping stone to the floor, with old-format values still in it (an old enum value, an old config key, an old file layout: whatever the audit in 5.4 found). Each has enough data to exercise every table and state file (a few rows per table, one of each file type), committed as a compressed fixture or produced by a script that checks out the release tags. The second fixture is the one that shows whether deleted readers were really unneeded; the sources repeatedly show that replay assumptions fail on real data.
- Upgrade from the floor. Copy each fixture, run the upgrade, assert the schema equals a fresh install and the data version is stamped, and assert what the data means afterwards: business rows, config values and files read back with the right meaning, including the old-format values from the second fixture. Also run it twice to confirm the second run is a no-op.
- Refusal leaves user data unchanged. For a below-floor fixture, and for unstamped, unknown, a database whose
-walis missing (stamp anduser_versiondisagree), a database that cannot be opened, and an interrupted-marker state the rules say to refuse, run the upgrade and assert the exit status and message (including which of the two states in 3.2 the user is in). Run each case in two set-ups. With the services already stopped, compare the file list and a hash of every file before and after; they must be identical. With a service running and holding a WAL-mode connection, compare each database's logical dump anduser_version, and the hashes of all non-database files; these must be identical, while the main database files' bytes may differ because of the shutdown checkpoint (3.2). This is the test that protects the no-corruption promise. - Fresh vs floor-plus-migrations schema equivalence, and boundary migrations and seed data applied exactly once (3.4).
- Interrupted upgrade. Kill the upgrade after the marker and before any change; after the first of two databases has committed; after all databases have committed and while files are being rewritten, including an upgrade that changes only files, so that no
user_versionmoves; and after the completion stamp and before the marker is cleared. Rerun each, and assert that it either reaches the target with the data meaning right, or refuses and points at the backup, as 5.1 defines. Add one state the write order cannot produce: a marker and a target completion stamp over a database or config file still in the source state (for example, a database copied without its-wal); assert that the run refuses, keeps the marker and changes nothing. - Concurrent start. Start two upgrades at once; start an upgrade while a service is running; and start an upgrade while a service has passed its startup check but not yet written anything. Assert mutual exclusion while locks are held: an upgrade never holds the exclusive lock while any service holds its shared lock, and a service never writes while the upgrade holds the exclusive lock. Whichever side cannot get its lock refuses without changing anything. A sequential handoff is a valid outcome: a running service may exit normally and release its shared lock, after which the upgrade takes the exclusive lock and proceeds.
Everything else (per-migration tests for removed versions) is deleted with the migrations. Inference: six tests are enough because they guard the rules (version check, write order, schema equivalence, data meaning), not the edge cases.
3.6 Knowing who is below the floor without central telemetry
The sources mostly solve this by policy rather than measurement: GitLab publishes stops and reports users trailing by years; Django says wait until "all systems are upgraded" or require in-order upgrades. A product with no central telemetry can use these signals, each of them weak:
- Package download counts per version. npm's registry documentation describes
GET https://api.npmjs.org/versions/{package}/last-week, with the caveat that "Download count for specific versions of a package are only available for the previous 7 days". It does not define what counts as a download (the page links to a separate explanation), and downloads are not installs: CI, mirrors and reinstalls inflate them. Useful as a ceiling on how old versions are still being fetched, not as a count of users. - A local, offline warning. The release before the floor can print, during
upgradeand in status output, a line such as the next minor will not upgrade from versions below X; you are on Y. This needs no network and reaches exactly the people who matter. It cannot reach people who never run upgrade, which is the group the floor will strand anyway. - An opt-in, anonymous version ping. This gives data but costs trust and adds a service to run and secure; for a privacy-sensitive self-hosted agent product it needs explicit consent and a clear description of what is sent. Whether it is worth it depends on how you feel about the privacy trade-off; the sources do not settle it.
- Support channels. Issue forms that ask for the version, release-note comment threads. Biased toward people who are already in trouble.
Be honest in the release notes about what you do not know, for example: we cannot see how many installations are below 1.0.0; if you are, do this first.
3.7 Communication: the stop is announced one release ahead
GitLab's rule is at least two milestones of notice; Django's is a whole release between squashing and deleting. For a small team with a slower cadence, I would argue for at least one full released minor of notice plus the stepping-stone documentation in place before the floor moves. Concretely:
- In the last release that still contains the migrations (a 1.0.x patch, or 1.0 final), add the warning from 3.6 and a release-notes section titled Upgrade floor that gives the date or release at which the floor moves and the stepping-stone version.
- In the release that moves the floor, put the floor in the first paragraph of the notes, again with the stepping-stone command, and in the docs page for upgrades.
- Keep a short page on upgrading from older versions permanently. Sentry's and Nextcloud's pages are the model: an explicit path example.
- If there is a machine-readable list of floors (GitLab's single-source-of-truth file), make the CLI's refusal read that, so docs and enforcement cannot drift.
3.8 A maintenance branch for the old line
The stepping stone has to stay usable. That means:
- Keep the last pre-floor line (here, 1.0.x) installable: do not unpublish it, and keep its tag and release artifacts. A broken stone is worse than no stone (Sentry's own list of versions to avoid shows how this goes wrong).
- Take fixes on that line only for what the stepping-stone role needs: data-safety bugs in migrations, install failures, security issues. Do not add features, and do not change the schema. A schema change on the stone line changes what the floor means and invalidates your fixtures.
- Branch from the release tag, fix on the branch and tag directly from it. That keeps the line's history auditable and avoids merging old-line fixes into the new line by accident.
- Say how long the line is supported. A floor with an indefinite stone is a promise you will not keep.
4. Why this matters especially for AI agent runtimes
This is short, because the general design above applies. Three agent-specific points:
- Unattended upgrades. Agent runtimes are often upgraded by a script or by an agent itself following a runbook. A refusal must be machine-readable (a distinct exit status and a stable message prefix), so an automated caller can tell a refusal for floor reasons from a failure, and must never prompt interactively. It should also carry the distinction from 3.2: data unchanged with the old program still installed, or data unchanged with the new package already installed.
- Long-lived state with user meaning. The data directory holds memory, conversation history and schedules that users value more than the code. Deleting the data and reinstalling is not an acceptable stepping stone for below-floor users; the stone must preserve data.
- Agents invent workarounds. An agent that sees a refusal may try to bypass it (edit the stamp, force-install) because the goal says to upgrade. The refusal text should say not to edit the stamp, and the override, if there is one, should be a deliberate, logged, human-level action. This is an inference from how automated runbooks behave, not from a source.
5. Failure modes
5.1 Half-migrated data directories
The upgrade touches several databases and files; it can die between them. The write order in 3.1 (stop services, lock, check, backup, marker, per-database commits, files, completion stamp, marker cleared) turns this from silent into detectable: a marker on the next start means a run did not finish. The marker does not say where the run stopped, and the version stamps cannot say either. An upgrade that only rewrites a config file leaves every user_version unchanged, so a crash just after the marker and a crash just after the config file's rename leave identical stamps; only the file contents differ. A database the upgrade does not migrate proves nothing about progress either. So recovery should not try to name the crash point. The next run stops the services, takes the lock, finds the marker, and:
- The marker names this run's source and target, the state file is still at the source, and each database's
user_versionis either its source or its target value: run steps 6 to 8 again. Because every step checks the data before acting (3.1), steps that already happened skip themselves and the rest run. This is safe only if every step really is idempotent in that way. If any step cannot tell whether it has run, the upgrade must refuse whenever it finds a marker and point at the backup, rather than guess. - The marker names this run's source and target, and the state file is already at the target: do not rerun anything. Verify the target state instead: every database at its target
user_versionwith the target schema, and every rewritten file in its new form. Only if all of that holds, clear the marker (step 8). If anything is still in the source state, keep the marker, refuse and point at the backup. A target stamp over source-state data is not a crash the write order can produce, since the stamp is written only after every database and file; it means something else happened, such as a lost-wal(3.2). Rerunning the steps would mark a directory that may already have lost data as complete, and clearing the marker alone would leave data the services cannot use. - Anything else (a marker for a different source or target, a state file at neither, a
user_versionthat is neither the source nor the target value for that database, a missing backup): refuse, change nothing, and point at the backup. - No marker: the normal rules apply (stamp and
user_versionagree, version at or above the floor).
Because the backup was finished before the marker was written, every state with a marker has a backup to point at. PostgreSQL's pg_upgrade documentation is clear about which steps invalidate the old data; borrow that precision for the message. Floor deletion makes this worse in one way: the resume path for a below-floor partial state has just been deleted, so the code must identify such a state and refuse, not attempt the missing migration.
5.2 Users who skipped releases
The Synapse 1.4.0 bug is the concrete example from this research: correct for the usual path, wrong for those who skipped. Sentry's page warns that for people who upgrade infrequently, going straight to the latest version is less likely to work; it gives no figures on how many users skip. Defences, in order of cost: set the floor above releases whose skip paths you cannot test; test the upgrade from the floor and from one middle release; document a stepping-stone path; and keep a post-upgrade check that reports anomalies (for example, a table that should be non-empty) rather than assuming success.
5.3 Rollback after a refused upgrade
A refusal must leave the old version runnable. The companion article covers data written by a newer binary; here the case is simpler if enforcement runs before any mutation. Even then, the two refusal states from 3.2 differ: after a layer-1 refusal nothing was installed, while after a layer-2 or layer-3 refusal the user's data is unchanged but the new package is already in place. Then rollback means reinstalling the old package against unchanged data, and the message must state that. Nextcloud's warning is the reminder of what happens otherwise: "Downgrading is not supported and risks corrupting your data". Rehearse the layer-2 refusal and the reinstall once. PostgreSQL's pattern of stating exactly when the old data stops being reusable is the model.
5.4 Data written by old code paths that later code still reads
This is the failure that a floor does not fix and deletion can create. Data written by pre-1.0 code and never rewritten by any 1.0.x release is floor-version data that new code must still read. Examples of shapes: an old enum value stored in a text column, a config key that older code wrote and the new code still reads with a fallback, a file layout. Before deleting a compatibility reader:
- List every place where the product reads persisted data (database columns, state files, config).
- For each, ask whether any data directory the floor accepts can contain an old shape that only this reader understands, whether floor-version code wrote it or older code wrote it and later releases carried it up unchanged.
- If yes, either keep the reader, or add a repair that runs during the upgrade in the target version and rewrites the old shape before anything reads it (then the runtime reader can go, but the repair stays as long as the floor does), or raise the floor to a release that already rewrote every occurrence.
- Prove the answer with the fixture that came up from an older release (3.5): it must contain the old shape, and the upgraded result must read back with the right meaning.
Django's note that migrations keep referencing functions and field classes is the same effect inside migration code: deleting an apparently unused helper breaks replay.
5.5 Deleting a migration that also repaired data
Migrations are written to change schema, but in practice many also repair data written wrongly by an earlier release. GitLab's rules point at this: existing migrations are not deleted in place, data-only migrations may be disabled only under listed prerequisites, and migrations are removed only after they have been part of a planned required stop. A squash records the schema a migration produced, not the repair it made. The check before removing any migration is to read its body for data statements (updates, deletes, inserts, file writes) and ask whether any data directory the floor accepts can still contain the broken data it fixes, including data carried up from releases older than the floor. If yes, move the repair into code that runs on floor-version data (and test it), or raise the floor. This is why the baseline must be generated from a floor-version database (3.4), not from the migration files: a dump contains the schema, not the repair.
5.6 Dependencies that moved
Rails' warning that old migrations "may fail to apply correctly if those migrations use changing external dependencies" and Django's historical-models warning describe the reason deleting is attractive, and why testing replay of old migrations is not a substitute for deletion plus a floor. If the migrations stay but call live code, they rot invisibly.
6. Trade-offs, honestly
- You may not need to delete anything. For a small product, frozen migration files that touch only SQL and no live application code cost little to keep. The strongest sources for deletion (Rails, Django) say replay breaks when migrations use evolving code or models; if yours do not, the benefit is smaller. The actual cost of keeping them is test and review time, and the confusion of states nobody can reach. I cannot quantify that; no source gives a number I could verify.
- A floor strands someone. Rails does not refuse; GitLab's package refuses and names the stop, and Sentry and Nextcloud document the path to hop. The stepping stone costs maintenance of the old line, and the more people below the floor, the more that costs. If you cannot afford the old line, set the floor lower.
- Early refusal vs best-effort upgrade. Synapse's looser stance ("you do not need to perform an upgrade to each individual version") is cheaper for users but relies on testing every skip path or accepting bugs like the 1.4.0 case. Strict stops (Nextcloud, GitLab) cost users more steps and reduce your test matrix. For a small team I lean towards strict, because the matrix grows quadratically with versions you accept (a simple counting argument, not a measured fact).
- One release of notice may be too little for a slow-moving user base. Self-hosted users of an agent platform may upgrade rarely; one released minor is a minimum. GitLab's two milestones is a reference point from a project with a fixed cadence.
- A tiny classifier is code you must keep correct. The Cherry Studio example above shows that even the decision between ready and recovery needs review. Keep it small, and test it with the fixtures from 3.5.
7. A recommended checklist for a small team
Before the release that moves the floor (1.0.x or the release right before):
- Choose the floor as the latest release whose migrations or repairs you still depend on; write it in one place (a constant plus a short manifest or docs entry).
- Ship the data-version stamp (atomic state file plus
user_versionper database), the upgrade-in-progress marker and the write order from 3.1 in the line that is still below the floor, so data has the stamp when users arrive at the floor. - Ship the offline warning, the release-notes Upgrade floor section and the stepping-stone docs; state when the line will stop receiving fixes.
- Produce the real floor fixtures (3.5): one created by the floor release, one carried up from an older release through the stepping stone with its old-format values kept; record their schema dumps.
- Audit persisted-data readers (5.4) and data-touching migrations (5.5); for each, write down the data invariant that allows deleting it (3.3), or what must be kept or moved into a target-version repair.
In the release that moves the floor:
- Implement the three enforcement layers (pre-install check if possible, pre-mutation check, startup guard), with services holding a shared lock for their whole life and the upgrade taking the exclusive lock; read versions from copies outside the data directory and refuse before any migration write (only the shutdown checkpoint from stopping services may come first), including when the read fails or the stamp and
user_versiondisagree; message gives current, required, stepping-stone, command, that user data is unchanged (byte-identical, or logically identical if services had to be stopped), whether the new package is already installed, and not to edit the stamp. - Generate the baseline from the floor release, not by hand, stamped with the last migration it includes; diff fresh-install schema against floor-plus-migrations, and check that boundary migrations and seed data run exactly once.
- Delete migrations and shims only after items 4 and 5 are done and their invariants hold on both fixtures; keep the version check, the classifier and the marker handling.
- Test (3.5): upgrade from both floor fixtures with data meaning asserted; refusal leaves user data unchanged (file hashes with services already stopped, logical dumps with a service running; including missing
-waland unreadable database); fresh versus upgraded schema equality and exactly-once boundary; interrupted upgrade at each crash point, including a files-only upgrade; concurrent upgrades and an upgrade racing a service that has passed its startup check. Run only these, plus anything the diff touches. - Tag the old line's last release, keep it installable, and keep fixes there schema-free.
After:
- Watch the signals from 3.6; answer below-floor reports with the stepping-stone command, not a custom fix.
- Before raising the floor again, repeat items 1 to 5 and give a full release of notice.
8. What I could not confirm
- GitLab: the upgrade-paths page states the sequence but no consequence for skipping a stop. I read the Omnibus
preinstrefusal (a package-version check), but not the charts upgrade check hook and not how the application usesMIN_SCHEMA_VERSION, so I cannot say what a below-minimum database itself produces. The cleanup issues and the pre-2019 squash were read through GitLab's API for the issue and merge-request descriptions, not their discussion threads. - Nextcloud: the skip-major refusal is in the server's
Updater.php, read on the master branch; I did not check older branches. I did not establish how the update server chooses which version to offer an instance, so I make no claim about it; the separate web updater contains a downgrade guard but no skip-major check. - Sentry: whether and how the install script detects the version being upgraded from and refuses to skip a hard stop is not stated on the page I read, and I did not read the script. The page gives no figures on how many users skip versions.
- Synapse: quotations from the upgrade notes were checked against the raw
upgrade.mdon the develop branch, which the published page is built from; I did not read every version's note. The schema page does not say when old deltas are deleted. - Flyway: I read the documentation, not the source. The Flyway baseline-migrations page on the documentation site was not retrievable at the URL I tried; the tutorial in the project repository covers the behaviour.
- Home Assistant, Discourse and Chromium: I searched for each project's minimum-upgrade policy and found nothing I could cite, so they are not covered. I also found no authoritative source on how Chromium or Electron apps delete profile migration code after a number of releases.
- SQLite and
user_versionuse for floors: the page says nothing on this; my application of it is design reasoning. The WAL read results in 3.2 come from my probe on Linux with SQLite 3.45.1 and 3.53.4 only; I did not test other platforms, other SQLite builds, or a real power failure, so the crash-durability statements in 3.1 rest on the SQLite andfsync(2)documentation, not on a test. For locking I probed shared and exclusiveflockrequests between separate processes on Linux only, not forked workers or other platforms. - npm per-version download counts: I read the registry documentation page for the endpoint and window; what counts as a download is defined on a separate page I did not open.
- Cost claims: no source gives numbers on how much maintenance old migration code costs, or how many installs sit below a given version. I did not invent any.
- Cherry Studio: the pull request was open when I read it (head
885d03e); its behaviour may change before or after merge. - All design elements in sections 3, 4 and 7 (the three-layer enforcement, the stamp, marker and write order, the copy-based read, the six-test set, the notice length, the quadratic-matrix argument) are my own reasoning from the sources above. Apart from the small SQLite probes in 3.1 and 3.2, I ran no upgrade, migration or rollback test to check them.
Sources
- https://docs.djangoproject.com/en/5.1/topics/migrations/
- https://docs.djangoproject.com/en/5.1/ref/django-admin/#squashmigrations
- https://guides.rubyonrails.org/active_record_migrations.html
- https://github.com/flyway/flyway/blob/main/documentation/Reference/Tutorials/Tutorial%20-%20Baseline%20Migrations.md
- https://documentation.red-gate.com/fd/baselines-273973441.html
- https://documentation.red-gate.com/fd/flyway-baseline-on-migrate-setting-277578974.html
- https://docs.gitlab.com/update/upgrade_paths/
- https://docs.gitlab.com/development/avoiding_required_stops/
- https://docs.gitlab.com/development/database/required_stops/
- https://docs.gitlab.com/development/database/deleting_migrations/
- https://gitlab.com/gitlab-org/gitlab/-/issues/370640
- https://gitlab.com/gitlab-org/gitlab/-/issues/409574
- https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31936
- https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/master/config/templates/package-scripts/preinst.erb
- https://develop.sentry.dev/self-hosted/releases/
- https://docs.nextcloud.com/server/latest/admin_manual/maintenance/upgrade.html
- https://github.com/nextcloud/server/blob/master/lib/private/Updater.php
- https://raw.githubusercontent.com/nextcloud/updater/master/index.php
- https://element-hq.github.io/synapse/latest/upgrade.html
- https://element-hq.github.io/synapse/develop/development/database_schema.html
- https://raw.githubusercontent.com/element-hq/synapse/develop/docs/upgrade.md
- https://kubernetes.io/releases/version-skew-policy/
- https://www.postgresql.org/docs/current/pgupgrade.html
- https://www.sqlite.org/pragma.html#pragma_user_version
- https://sqlite.org/wal.html#read_only_databases
- https://www.sqlite.org/lang_attach.html
- https://man7.org/linux/man-pages/man2/fsync.2.html
- https://man7.org/linux/man-pages/man2/flock.2.html
- https://raw.githubusercontent.com/npm/registry/main/docs/download-counts.md
- https://github.com/CherryHQ/cherry-studio/pull/25469
