Repository navigation
feat(startup): newer-database recovery flow - #1405
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoAdd safe recovery for newer databases during startup
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
d45788f to
aa3c9db
Compare
aa3c9db to
858dae1
Compare
Intercept SchemaVersionMismatchError during startup before generic error handling and present a dedicated newer-database recovery flow offering Get Latest Version, Open Backups Folder, Restore Compatible Backup, and Exit. Inspect candidate backups by SQLite content rather than filename, require explicit data-absence confirmation before restore, preserve the newer database and any -wal/-shm sidecars in backups/, and coordinate replacement through the atomic database replacement journal before continuing normal startup initialization. Fixes #1341
…, auth, and validation"}
…duplicate backups
…match duck-typing
… and async scan - Refuse active flo.db-journal rollback journals before archiving, writing a replacement journal, or mutating active files, and clear stale -journal sidecars during replacement and interrupted recovery. - Fall back to private .flo-db-stage-* staging on the database volume when os.tmpdir() snapshot staging fails, failing closed only when neither volume can stage and cleaning stranded stage directories at startup. - Inspect canonical _flo_meta.schema_version alongside PRAGMA user_version in non-mutating preflight, replacement health checks, and runMigrations. - Prefilter non-SQLite and header-newer backup candidates via readSqliteHeaderInfo and yield between candidates in discoverDowngradeBackupsAsync.
…narrow discovery contract
19909c6 to
0e7ccc8
Compare
Fixes #1341
Behavior
When an older FloCafe app build opens a database created or migrated by a newer app version (
PRAGMA user_version > LATEST_SCHEMA_VERSION), startup interceptsSchemaVersionMismatchErrorbefore the generic error box and presents a dedicated recovery dialog. Users can download the latest version, open the backups directory, restore a compatible backup after explicit confirmation, or safely exit without touching any files.Design Decision
FloCafe uses forward-only migrations and never attempts lossy or speculative reverse migrations. Safe recovery from an older binary opening a newer database provides guided upgrade paths or restores a validated pre-upgrade backup while preserving the newer database and all active sidecars in a timestamped recovery archive with atomic replacement journal protection.
Migration Implications
None. This change introduces no database schema migrations, table alters, or persistent state changes.
Tests Run
npm run test:newer-db-recovery: verifies non-mutating preflight checks, header vs WAL inspection, compatible backup discovery, cancellation safety, journaled replacement, sidecar preservation, and simulated ENOSPC/IO storage error resilience.npm run test:backup: verifies backup creation, integrity inspection, and direct restore workflows.npm run test:shutdown-lifecycle: verifies clean shutdown and quiescent connection draining.npm run docs:check: markdown lint, link validation, and doc policies.npm run lintandnpm run build: typecheck and Oxlint checks.Remaining Limitations
Restoring requires an intact compatible backup; if no compatible backup is available, the user must update FloCafe to a version supporting the database schema.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ No issues found.
✅ **Document** - passed
✅ No issues found.
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.