Apply pending migrations during development reloads

This commit is contained in:
syntaxbullet
2026-09-04 19:01:16 +02:00
parent 865bdd1328
commit 392deb9cbe
3 changed files with 65 additions and 2 deletions

View File

@@ -143,8 +143,11 @@ bun run db:migrate
```
Commit the generated `drizzle/` files alongside schema changes. `bun dev` and
`bun start` apply pending migrations before starting the server. The initial
migration creates the users and sessions tables.
`bun start` apply pending migrations before starting the server. Development also
checks for pending migrations when the server entrypoint is hot-reloaded, so new
routes do not run against an older schema. After adding only migration files,
run `bun run db:migrate` or restart `bun dev`. The initial migration creates the
users and sessions tables.
Import `db` from `src/db/index.ts` in backend code to query the database.
`GET /api/health` checks the database connection before returning success.