prisma / prisma-examples

🚀 Ready-to-run Prisma example projects

Home Page:https://www.prisma.io/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postgresql-supabase instructions missing db seed step

kiptoomm opened this issue · comments

In this repo https://github.com/prisma/prisma-examples/tree/latest/databases/postgresql-supabase, the following error occurs when running the last step (npm run dev) in the README instructions:

No 'User' record(s) (needed to inline the relation on 'Post' record(s)) was found for a nested connect on one-to-many relation 'PostToUser'.

The README should be updated to include the database seeding step prior to running the script e.g:

npx prisma db seed

Full output
$ npm run dev
> supabase-postgresql@1.0.0 dev
> ts-node script.ts

Retrieved all published posts:  []
PrismaClientKnownRequestError:
Invalid `prisma.post.create()` invocation in
~/postgresql-supabase/script.ts:13:37

  10 console.log('Retrieved all published posts: ', allPosts)
  11
  12 // Create a new post (written by an already existing user with email alice@prisma.io)
→ 13 const newPost = await prisma.post.create(
An operation failed because it depends on one or more records that were required but not found. No 'User' record(s) (needed to inline the relation on 'Post' record(s)) was found for a nested connect on one-to-many relation 'PostToUser'.
    at _n.handleRequestError (~/postgresql-supabase/node_modules/@prisma/client/runtime/library.js:123:6854)
    at _n.handleAndLogRequestError (~/postgresql-supabase/node_modules/@prisma/client/runtime/library.js:123:6188)
    at _n.request (~/postgresql-supabase/node_modules/@prisma/client/runtime/library.js:123:5896)
    at async l (~/postgresql-supabase/node_modules/@prisma/client/runtime/library.js:128:10871) {
  code: 'P2025',
  clientVersion: '5.10.2',
  meta: {
    modelName: 'Post',
    cause: "No 'User' record(s) (needed to inline the relation on 'Post' record(s)) was found for a nested connect on one-to-many relation 'PostToUser'."
  }
}