Is there a way to rename a named relations? e.g. o...
# orm-help
y
Is there a way to rename a named relations? e.g. original:
Copy code
type User {
  id: ID! @unique
  name: String!
  posts: [Post!]! @relation(name: "UserOnPost")
}

type Post {
  id: ID! @unique
  title: String!
  user: User! @relation(name: "UserOnPost")
}
changed datamodel:
Copy code
type User {
  id: ID! @unique
  name: String!
  posts: [Post!]! @relation(name: "PenisOnPost")
}

type Post {
  id: ID! @unique
  title: String!
  user: User! @relation(name: "PenisOnPost")
}
I keep getting
✖ You are creating a required relation, but there are already nodes that would violate that constraint.
when
prisma deploy
@fgreinus --force does not work. It is not a warning; its an error
f
Okay, maybe you have to use the @rename annotation
y
@rename
works when renaming the field e.g.
user
->
doctor
but I cannot figure out how to use for the relation name
f
I think i understand the problem. Normally prisma would delete the old relation and create the new one (with the new name)
y
genau 🙂
f
But you marked the relation as not nullable - so a post always has to have a user
Kann er dann natürlich nicht migrieren, da das sonst verletzt werden würde, da es schon Posts gibt 😛
you'd have to delete all posts prior to migrating i guess
y
but I think expected behavior is that it simply renames?
I guess I file an issue
f
yes, seems like a missing feature
f
👍