fix(db): apply migrations by hash + recover workspace->task rename #500
+280
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Title
fix(db): robust migrations (hash-based), recover workspace→task rename, and add DB setup telemetry
Why (Product/User focus)
SQLITE_ERROR: no such table: tasksafter updates.Application Support/Electron) and appears empty..dmgusers) by ensuring new migrations always apply, even if their DB has a “weird” history.What changed (Engineering focus)
Migrations now apply by missing hash (not timestamps)
sqlite-proxymigrator can skip migrations forever if a DB has newercreated_atvalues than the new migration’swhen.readMigrationFiles()and apply any migration whose hash is not in__drizzle_migrations.Foreign key safety during schema transitions
PRAGMA foreign_keys=OFFand restoreONafter, preventing failures on legacy/orphaned data during table rebuild migrations.Recovery for partial workspace→task rename migration
__new_conversationsexists) and completes the migration so DB doesn’t get stuck.Manual-fix safe
workspaces → tasksrename but the migration wasn’t recorded, we mark it applied without re-running destructive SQL.Dev DB path correctness + continuity
app.setName('Emdash')happens before anyapp.getPath('userData')calls (prevents defaulting toApplication Support/Electron).resolveDatabasePath()now attempts to migrate an existingemdash.dbfrom sibling legacy dirs (e.g.Electron/) into the current app’s userData.Telemetry
db_setupevent (privacy-safe):outcome,applied_migrations(_bucket),recovered, anderror_typeon failure.Files changed
src/main/services/DatabaseService.tssrc/main/db/path.tssrc/main/entry.tssrc/main/main.tssrc/main/telemetry.tsHow to test
workspaces: start app → migrations run →tasksexists,workspacesgone, no “no such table: tasks”.__new_conversationsleftover): start app → recovery completes → no leftover__new_*.Electron/) and legacy DB is migrated if present.Notes / Safety