Prisma integration example fails in build
Could someone help me try to reproduce a bug I get in the official
npm init solid@latest
?
1. npm init solid@latest
2. Select the following options: Solid-Start: Yes, TypeScript: Yes, template: "with-prisma"
3. cd into project folder
4. npm install
5. npx prisma generate
6. npx prisma migrate dev
7. npm run dev
8. Open "localhost:3000". Interact with the site. Register a user, login, logout. Observe correct behavior.
9. npm run build
10. node .output/server/index.mjs
11. Open "localhost:3000". Interact with the site. Register a user, login, logout. Observe it's impossible. Error: Invalid
prisma.user.findUnique() invocation: The table
main.User does not exist in the current database.
I wrote an issue on the Prisma repo here: https://github.com/prisma/prisma/issues/24845
but I don't see other people with this error so it might be something in the Solid/Vinxi ecosystem.6 Replies
Did you try to run
npx prisma migrate dev --name init
After build like in the comment you linked from the other issue?
Thing is, I don't want to build like the comment I linked. I want to use SQLite and not Postgres and it had been working in the past. I have tried running that command without changing db type but it does nothing.
@zimo The reason for it failing in the prod build is because the prod build copies the schema to .output. But the database url is relative to the schema. To work around it, i recommend to provide an absolute database_url. You can resolve the absolute url from the relative one during runtime 🙂. This is how I am doing it:
https://codeberg.org/nitropage/nitropage/src/commit/0a5fdc9603aba5867ebc904cb75ebef0a1a7a68c/packages/internals/src/server/prisma.ts#L28
Oh my God this is it. I tried changing the URL in an earlier attempt but I think it failed when I gave it a sham path, so I just assumed this was not the error. But it must have found the Schema but not the db file just like you said. It all makes sense now. Thank you as always Katja :)
My pleasure 🥳, I am looking forward to see the results of your work 🤩
yes hopefully soon :)