w3cj / hono-open-api-starter

A starter template for building fully documented type-safe JSON APIs with Hono and Open API
https://www.youtube.com/watch?v=sNh9PoM9sUE
MIT License
328 stars 34 forks source link

How to work with sqlite in memory? #15

Closed thebspin closed 3 weeks ago

thebspin commented 3 weeks ago

Hi,

I've found out that instead of providing an url you can also set the database url to :memory:. It seems to connect but it also seems that execSync("pnpm drizzle-kit push"); is not doing anything. I assume this because of this error that i'm getting:

Object {
  "message": "SQLITE_ERROR: no such table: tasks",
  "stack": "LibsqlError: SQLITE_ERROR: no such table: tasks
  ...

Any possible idea what's going wrong?

w3cj commented 3 weeks ago

pnpm drizzle-kit push creates a new process (different memory) so the migrations applied will not effect the database in memory for the tests.

For :memory: to work for tests, you would need a way to run the migrations programmatically within the same process as the tests.