Closed zimonitrome closed 4 months ago
This happens whenever I try to query anything in the database. I looked into the compiled code which does something like:
p = new PrismaClient();
This object seems nice and correct. I can console.log it and see all definitions. p.session
and p.user
and all other tables exist and I can print those as well. But whenever I await p.user.findFirst()
or do any other query operation, I get the above error that The table
main.Userdoes not exist in the current database.
.
I have tried manually setting the URL in dev and build. If I set it incorrectly it lists another error, that the db could not be found. So it seems like it can locate the db file, it has the definitions, but actually reading the db file or finding the corresponding definitions fail.
I have obviously migrated and re-migrated my db, but still nothing helps.
This is really weird because previous versions of the repo that were seemingly working are all now giving the same error.
Posting this here for my own sanity since it seems relevant:
https://github.com/prisma/prisma/issues/10633#issuecomment-1570048865
Turns out new versions of Vinxi copies the schema to the output directory but not the db. So when searching for the Prisma files, the schema was found but not the db file.
The solution is to use an absolute path to the database (.bd
) file when initializing the PrismaClient. Doing this with:
const prisma = new PrismaClient({datasourceUrl: process.env.PRISMA_URL});
Bug description
I have a SolidStart webapp with AuthJS and Prisma that runs fine in dev, but in build it fails and throws the following error:
The table `main.<tablename here>` does not exist in the current database.
.I found the recent issue: https://github.com/prisma/prisma/issues/24779 And tried upgrading to
5.18.0-integration-fix-config-dir-client.5
but still got the same error.It probably has to do with SQLite integration. Similar issue found here without reproduction: https://github.com/prisma/prisma/issues/10633#issuecomment-1570048865
How to reproduce
npm init solid@latest
npm install
npx prisma generate
npx prisma migrate dev
npm run dev
npm run build
node .output/server/index.mjs
Invalid
prisma.user.findUnique()invocation: The table
main.Userdoes not exist in the current database.
Expected behavior
Expected to work in build as it does in dev.
Prisma information
and
But it could be any code using prisma through the normal client also.
Environment & setup
Prisma Version