Skip to content

Warn when DB migrations are pending (restart needed) #75

Description

@ApocDev

When a new Drizzle migration is added while the dev server is running, the server keeps its already-open SQLite connection and never applies it (provision only runs migrations on first connect). Query code that references the new schema then errors against the old columns, and the UI silently comes back empty — with no hint that the real fix is just to restart the server.

Repro

  1. Run the dev server.
  2. Add a migration that alters a table the running queries read (e.g. a new column on blocks).
  3. Hot-reload picks up the new query code, but the open connection to the active project DB still lacks the column. Every list that selects it returns empty, with no visible explanation.

Desired behavior

Detect pending migrations and surface a clear banner, e.g. "Database migrations pending — restart the server to apply." Show which project DB and how many migrations are behind.

Detection

Compare the migration tags bundled in the build (drizzle/meta/_journal.json) against the rows recorded in the active project DB's __drizzle_migrations table. Bundled tags not present in the DB journal = pending. A lightweight server fn can return the count/list; the app shell polls it and renders the banner when non-zero.

Notes

  • Practically dev-only: a packaged build provisions on first connect, so it will not normally drift. The banner is still cheap insurance.
  • Out of scope (but worth a mention): dev could optionally watch drizzle/ and re-run migrateConnection on the cached connection to auto-apply — but an explicit "restart" banner is the simpler, less surprising first step.
  • Relevant code: server/provision.ts (migrateConnection), db/index.ts (cached connection), server/paths.ts (data dir / project db).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: webWeb UI (React/TanStack/vite-plus)enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions