Skip to content

Upgrade path for @relation from preview to beta #2048

Answered by nikolasburk
brandonweiss asked this question in Q&A
Discussion options

You must be logged in to vote

Hey Brandon 👋 I've added a new section to the top of the release notes that explains the concrete upgrade path for the relation syntax!

Basically you don't need to touch the DB and can manually adjust your Prisma schema like so:

model User {
  id      Int      @id @default(autoincrement())
  profile Profile?
}

model Profile {
  id      Int     @id @default(autoincrement())
  user    User    @relation(fields: [userId], references: [id])
+ userId  Int     @map("user") // relation scalar field (used in the `@relation` attribute above)
}

model Post {
  id         Int         @id @default(autoincrement())
  author     User        @relation(fields: [authorId], references: [id])
+ authorId   I…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@nikolasburk
Comment options

@brandonweiss
Comment options

Answer selected by brandonweiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants