Unable to find table (not available) but it exists
The table (not available) does not exist in the current database.
code: 'P2021', clientVersion: '5.7.0', meta: { modelName: 'DraftItem', table: '(not available)' }
I can GUARANTEE you that DraftItem exists. Doesn't happen for other tables, happens to multiple devs, seems to work fine once its deployed.. our running app works fine. Its just connecting to the dev database locally that it doesn't work.
Anyone have ideas on this? Asked AI and it didn't help unfortunately.
2 Replies
Hello @Jay Bell 👋
Can you please confirm if you have invoked
npx prisma generate
command?
Also, what happens if you invoke npx prisma db pull
command? Do you get DraftItem
model in your schema.prisma
file?
https://www.prisma.io/docs/orm/reference/prisma-cli-reference#db-pullPrisma CLI reference | Prisma Documentation
This page gives an overview of all available Prisma CLI commands, explains their options and shows numerous usage examples.
Hey Nurul, yes I have generated it, made sure to check that first. And when I pull I do get it yes.
So create and findMany work fine, upsert is failing. Trying to track down whats going on there.
Reproduced it in a fresh database.
So we have an empty DraftItem record (existing db row, was a placeholder table for months). We are upserting those records to ensure they are completely filled in now (since the table is in use)
So we are updating the DraftItem with some fields and then also upserting a nested 1:1 relation (Inventory).
This is where it fails, if I just upsert that DraftItem and do not try and also upsert inventory it works, as soon as I try and upsert Inventory it does not work.