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
- Run the dev server.
- Add a migration that alters a table the running queries read (e.g. a new column on
blocks).
- 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).
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
blocks).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_migrationstable. 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
drizzle/and re-runmigrateConnectionon the cached connection to auto-apply — but an explicit "restart" banner is the simpler, less surprising first step.server/provision.ts(migrateConnection),db/index.ts(cached connection),server/paths.ts(data dir / project db).