S
SolidJS•5mo ago
zimo

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
Madaxen86
Madaxen86•5mo ago
Did you try to run npx prisma migrate dev --name init After build like in the comment you linked from the other issue?
zimo
zimoOP•5mo ago
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.
Katja (katywings)
Katja (katywings)•5mo ago
@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
zimo
zimoOP•5mo ago
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 :)
Katja (katywings)
Katja (katywings)•5mo ago
My pleasure 🥳, I am looking forward to see the results of your work 🤩
zimo
zimoOP•5mo ago
yes hopefully soon :)
Want results from more Discord servers?
Add your server