Skip to content

feat(updater): back up local data before an update, refuse a newer schema untouched, explain the channel row on package installs (#1497) - #1710

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
feat/update-backup-schema-guard
Oct 18, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
feat/update-backup-schema-guard

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1497. Part of the Beta channel epic #1499.

A beta can carry a newer local database schema than the stable it is promoted to, and nothing protected the user from that, or told a package-manager user that the channel setting does nothing for them.

Backup before an in-app update

  • UpdateBackup (lib/core/storage/update_backup.dart) copies querya.db and its -wal to querya.db.pre-<from>-<to>.bak, keeps the newest 3 (a copy's -wal goes with it) and deletes older ones. Versions are sanitised in the name.
  • LocalDb.backupBeforeUpdate closes the database, makes the copy and leaves reopening to the next query.
  • The update dialog calls it right before installing (after the unsaved-work confirmation). If it fails, a dialog says so and offers Cancel or Install without a copy.

Newer-schema guard

  • LocalDb passes onDowngrade and throws LocalDbNewerSchemaException(found, supported, path). The throw happens inside sqflite's open transaction, so it rolls back and the file keeps its version number; without it sqflite stamps the older number on the file and the build carries on with tables it does not know. The recovery screen already prints the error; the message names the newer data format and the .bak to restore.

Release channel row (Preferences → General)

  • On a Snap, Flatpak, AUR, .deb or .rpm install (UpdateInstallContext.isPackageManagerInstall) the dropdown is disabled, shows Stable and the hint says updates come from the package manager (stable only).
  • AppUpdaterService.checkForUpdates reads releases/latest there whatever the stored channel is, so such an install is not told about a beta it cannot install.

Docs: docs/user-guide.md ("Updates, betas and going back": channels, the pre-update copy, how to go back by restoring it) and docs/security.md (schema version and the guard).

Not done: a stored "schema version" separate from sqflite's user_version (it already is the schema version: _dbVersion = 13); a button in the recovery screen that restores the newest .bak (the file name is in the message and the user guide describes the manual steps).

Tests: backup naming, WAL copy and removal of a stale WAL copy, keeping the newest three with their WALs, a missing database; LocalDb backup then reopen; a database set to a newer user_version is refused with the right numbers and its version is still the newer one afterwards; the channel row on a portable and on a package install; a package install reading releases/latest while the stored channel is Beta; the update dialog copies before installing, asks when the copy fails, and honours Cancel and Install without a copy.

…fuse a newer schema without changing it, explain the channel row on package installs (#1497)
@github-actions github-actions Bot added enhancement New feature or request P3 Low priority / Polish & Enhancements labels Oct 18, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit adbb65f into dev Oct 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request P3 Low priority / Polish & Enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant