Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Prisma issues due to client being generated in the api workspace #4605

Closed
3 tasks done
dac09 opened this issue Mar 1, 2022 · 4 comments
Closed
3 tasks done
Assignees

Comments

@dac09
Copy link
Contributor

dac09 commented Mar 1, 2022

Prisma throws errors when trying to access models, in the seed scripts, exec scripts or services.

Invalid `db.post.create()` invocation in
/Users/dac09/Experiments-28feb-1049/scripts/seed.ts:24:41

  21
  22 Promise.all(
  23   posts.map(async (post) => {
→ 24     const newPost = await db.post.create(
  The table `main.Post` does not exist in the current database 

Diagnosis

Looks like in yarn 1 workspaces, sometimes prisma will create the .prisma folder at one or more of the nested workspaces. Deleting the generated folder fixes the problem

So the migrations and generation produces the client in the root node_modules/.prisma but when running the api side code, it picks a different prisma client, causing this error

In our case:

├── node_modules
│   ├── .prisma # 👈 this is good!
├── web
│   ├── node_modules
├── api
│   ├── node_modules
│   │   ├── .prisma  # 😨 whai?

Node version: v16.13.1
Yarn version: 1.23.0-20220130.1630 (set using yarn version classic)

Tasks

@jvanbaarsen
Copy link
Contributor

I can confirm this is also happening with yarn 3. I just created a brand new redwoodJS app, and ran into this problem as well.

@lyonusi
Copy link

lyonusi commented Mar 21, 2022

I'm doing the tutorial and ran into this problem at Getting Dynamic after yarn rw prisma migrate dev. Temporarily fixed by rm -rf api/node_modules/.prisma. Node 16.14, yarn 1.22, prisma 3.10. Spent half my day trying to figure out what is going on...

@thedavidprice thedavidprice moved this from In progress to RC.Ultimate in Release Mar 21, 2022
@thedavidprice
Copy link
Contributor

@lyonusi Gah, that's so frustrating. So sorry. This is a particularly annoying bug... 😖

Update

Prisma is moving forward with a fix. The tests on a pre-release version are looking good here #4850

Need to wait for a Prisma patch or minor release, then we'll get this merged into a Redwood release. Soon!

@thedavidprice
Copy link
Contributor

Closed by

I'll patch RC and release rc.final.2

@jtoar jtoar moved this from RC.Ultimate to Done in Release Mar 25, 2022
@jtoar jtoar moved this from Done to Archived in Release Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Archived
Development

No branches or pull requests

5 participants