mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Completes the #6492 data-safety system on the WeKan side (FerretDB detection/repair/cap landed in the fork): - Decision brain: models/lib/recoveryPlan.js decideRecovery() picks the least-invasive recovery when the database is KNOWN corrupt (latest good backup -> previous backup -> re-migrate from MongoDB -> manual). It never acts on a healthy/unknown database and never restores a known-bad backup. - Startup restore/re-migrate: every FerretDB launch path (snap, bundled release, Docker) can restore the text data BEFORE FerretDB opens the files, on request (WEKAN_FORCE_RESTORE env or a RESTORE_REQUESTED marker). It copies a known-good backup INTO the live database (dropping stale WAL side-files); backups are never deleted and the main wekan.sqlite is only overwritten, never removed. remigrate is delegated to migration-control. Attachments/avatars on the filesystem are untouched. - Recovery events: the scripts append JSON lines to recovery-events.jsonl; the server (server/recovery.js) imports them into the recoveryEvents collection on startup, plus an admin-only recordRecoveryEvent method. - Admin Panel / Problems / Recovery: a new admin-only report (server/publications/recoveryReport.js, wired in adminReports.js/.jade + i18n) lists the remediation history newest-first, readies up front and fetches directly (no hang). - Docs: docs/Features/Admin-Panel/Problems/Recovery.md. Tests (wired into npm run test:unit:node), verified by mirror since there is no Node runtime here to execute them: - recoveryPlan.test.cjs (decision logic, positive + negatives) - recoveryEventsJsonl.test.cjs (parser: skips junk, normalizes severity, never throws) - recoveryReportQuery.test.cjs (search selector escapes regex metacharacters) - recoveryReportWiring.test.cjs (report wired; publication/count/method admin-gated) - ferretdbTextDataBackup.test.cjs extended: restore copies from a backup, is request-gated, and NEVER deletes the live text data or a backup copy Thanks to bluetopaz1204, mueschel and xet7 ! Fixes #6492,