- We were updating global schema before migrating userdata, but a 4 → 5
upgrade involved a system.sql version bump, which wiped out itemTypes,
causing 'annotation' to not exist after the upgrade. This moves global
schema updates after userdata migration and bumps the global schema
version to repair DBs that were already upgraded and broken.
- A system.sql bump without a global schema update would result in empty
tables. This moves the global-schema-related tables to userdata.sql.
- The DB integrity check before userdata updates added in 5b9e6497a
could fail when coming from an older DB, because the checks assume
current schema. An integrity check is now done after a userdata update.
(We were already skipping the new table/index reconciliation stuff. If
old DBs are discovered to have problems that would cause a migration
step to fail, we'll fix those explicitly in the steps.)
Also:
- Make sure `version` is `versionNumber` in the `fields` table. It was
changed with a system.sql bump in 5.0, but hard-coded fields were later
removed from system.sql in favor of schema.json, meaning that anyone who
upgraded from 4.0 after that would never have `version` removed and so
would have both fields (one from before and one from schema.json).