@@unique is no longer allowed for relations in vscode plugin
See original GitHub issueProblem
i had a model like this:
model TeamChallengeVote {
id String @default(uuid()) @id
user User @relation(references: [id])
challenge Challenge @relation(references: [id])
team Team? @relation(references: [id])
score Int
@@unique([user, challenge, team])
}
until yesterday, this was valid. But since today, vscode complains about the @@unique annotation:
Error validating model "TeamChallengeVote": The unique index definition refers to the relation fields user, challenge, team. Index definitions must reference only scalar fields.
i guess this is of the new beta which unfortunatly requires additional scalar fields. So the formatter already threats the schema as beta, altough we still use preview
Solution
maybe the formatter just needs to know the prisma version for the time being and treat at as preview schema. Its very very hard for the moment to know how to migrate properly, everything seems to fall apart.
Alternatives
Have the formatter automatically update every schema in a way that it works both for preview version and beta. Maybe release another preview that supports the new scalar fields and have the migration handle this gracefully. Or get rid of the scalar-fields again on beta.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)

Top Related StackOverflow Question
👍
the good formatter in vscode really helped to adopt anyway as it adds missing pieces
Closing this now since the syntax change was completed more than 6 months ago.