Skip to content

Conversation

@anantham
Copy link
Owner

Summary\nAdd a migration safety net for IndexedDB upgrades: version gate + automatic pre-migration backups + restore path.\n\n## Root Cause\nSchema upgrades previously ran without a safety backup and without a guardrail for "DB newer than app" scenarios.\n\n## Changes\n- [ ] services/db/core/versionGate.ts: peek DB version (no upgrade) and return actionable status\n- [ ] services/db/core/migrationBackup.ts: export-and-store backup before upgrades (tiered storage)\n- [ ] services/db/core/migrationRestore.ts: restore from backup / emergency restore helper\n- [ ] services/db/core/connection.ts: add prepareConnection() + integrate safety flow; avoid open() stampede\n- [ ] services/db/core/errors.ts: treat DbError kind 'Version' as requiresUserAction\n- [ ] tests/db/migrations/*: add coverage for version gate, backup, restore\n\n## Testing\n- [x] npx tsc --noEmit\n- [x] npm test -- --run\n\n## Review Checklist\n- [x] No direct commits to main\n- [x] One issue per PR\n- [x] Tests pass locally\n\n## Follow-ups\n- services/db/core/connection.ts is ~346 LOC (above the 300 LOC guideline); consider a small decomposition PR later.

Context: Add a safety net around IndexedDB schema upgrades.

Changes: Introduce prepareConnection/version gate checks; create tiered pre-migration backups; add restore/emergency restore flows; add regression tests.

Impact: Prevents silent data loss during upgrades and blocks opening a newer DB with an older app.

Tests: npx tsc --noEmit; npm test -- --run

Docs: Updated docs/WORKLOG.md
@vercel
Copy link

vercel bot commented Dec 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
lexicon-forge Ready Ready Preview, Comment Dec 22, 2025 8:45am

@anantham anantham merged commit 61e43bd into main Dec 22, 2025
3 checks passed
@anantham anantham deleted the feat/migration-safety-2-integration branch December 22, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants