question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Panic: Did not find a relation for model

See original GitHub issue

I’m using prisma 2.13.1.

model Movie {
  id       String           @id @default(cuid())
  title    String
  slug     String           @unique
  synopsis String
  year     Int
  runtime  Int
  imdb     String           @unique
  rating   Float
  poster   String
  genres   String[]
  cast     ActorsOnMovies[] @relation("ActorsOnMovies")

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Actor {
  id     String           @id @default(cuid())
  imdb   String           @unique
  name   String
  movies ActorsOnMovies[] @relation("ActorsOnMovies")

  createdAt DateTime @default(now())
  updtedAt  DateTime @updatedAt
}

model ActorsOnMovies {
  actorId   String
  actor     Actor  @relation("ActorsOnMovies", fields: [actorId], references: [id])
  movieId   String
  movie     Movie  @relation("ActorsOnMovies", fields: [movieId], references: [id])
  character String


  @@id([actorId, movieId])
}

Then I run prisma db push --force --preview-feature and I get:

Running generate... (Use --skip-generate to skip the generators)
Error: Schema parsing
thread 'main' panicked at 'Did not find a relation for model Actor and field movies', libs/prisma-models/src/datamodel_converter.rs:80:29
stack backtrace:
   0: _rust_begin_unwind
   1: std::panicking::begin_panic_fmt
   2: prisma_models::datamodel_converter::DatamodelConverter::convert_fields::{{closure}}::{{closure}}
   3: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   4: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   5: prisma_models::datamodel_converter::DatamodelConverter::convert
   6: query_engine::main::main::{{closure}}::main::{{closure}}
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   8: std::thread::local::LocalKey<T>::with
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  10: async_io::driver::block_on
  11: tokio::runtime::context::enter
  12: tokio::runtime::handle::Handle::enter
  13: std::thread::local::LocalKey<T>::with
  14: std::thread::local::LocalKey<T>::with
  15: async_std::task::builder::Builder::blocking
  16: query_engine::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, May 5, 2022
0reactions
schwarzskycommented, May 4, 2022
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb", "fullTextSearch"]
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

model editedmessages {
  id          String   @id @default(auto()) @map("_id") @db.ObjectId
  userId String
  oldMessage String
  newMessage String
  editDate String
  messageID String
  user   users   @relation("users", fields: [userId], references: [userId], onDelete: NoAction, onUpdate: NoAction)
  users  users[]
}

model stafftags {
  id          String   @id @default(auto()) @map("_id") @db.ObjectId
  v           Int      @map("__v")
  fullMessage String
  type        String[]
  userId      String
}

model statistics {
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  v     Int    @map("__v")
  date  String
  total Int
  type  String
}

model users {
  id               String           @id @default(auto()) @map("_id") @db.ObjectId
  v                Int              @map("__v")
  avatarURL        String
  firstMessage     String
  lastMessage String?
  userId           String           @unique(map: "userId_1")
  username         String           @unique(map: "username_1")
  statistics       userstatistics   @relation(fields: [userId], references: [userId])
  userstatistics   userstatistics[] @relation("users")
  message       editedmessages   @relation(fields: [userId], references: [userId])
  editedmessages   editedmessages[] @relation("users")
}

model userstatistics {
  id     String  @id @default(auto()) @map("_id") @db.ObjectId
  v      Int     @map("__v")
  total  Int
  userId String
  user   users   @relation("users", fields: [userId], references: [userId], onDelete: NoAction, onUpdate: NoAction)
  users  users[]
}

model webusers {
  id       String  @id @default(auto()) @map("_id") @db.ObjectId
  username String
  password String
  email    String
  admin    Boolean
}

Throws an error,

❯ npx prisma format
Prisma schema loaded from prisma\schema.prisma
thread '<unnamed>' panicked at 'Did not find a relation for model users and field editedmessages', query-engine\prisma-models\src\builders\internal_dm_builder.rs:122:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Unexpected token D in JSON at position 0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Panic following trauma: the etiology of acute posttraumatic ...
Posttraumatic panic was modestly predicted by childhood sexual abuse (CSA) experiences, a history of Anxiety and Depression, and peritraumatic dissociation.
Read more >
Query with N to M Panics - Stack Overflow
I have two model in prisma one to many relation but i want to insert data into second model how to do this?...
Read more >
Marriage in a panic: Panic disorder and intimate relationships
Panic disorder and agoraphobia often have a negative influence on the relationship and the non-affected partner. Partnership problems can be ...
Read more >
Intimate partner violence (battered woman syndrome)
People who find themselves in an abusive relationship often do not feel ... have intense feelings of fear; have panic attacks or flashbacks...
Read more >
Agoraphobia in adults: Incidence and longitudinal relationship ...
This finding was not surprising. However, the finding that baseline agoraphobia without spontaneous panic attacks also predicted first-onset panic disorder ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found