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.

@id @unique on id error should be highlighted when creating schemas and db push should fail

See original GitHub issue

Bug description

I noticed Prisma doesn’t reject or complain for error "@unique": Fields that are marked as id should not have an additional" until when the schema has been pushed to db then error would pop out in Prisma studio. I think this can improved by letting developer know before hand!

How to reproduce

example:

  model Payment {
  paymentId String   @id @unique
  date      DateTime @default(now())
  amount    Int
  success   Boolean  @default(true)
  order     Order[] 
                 }

with the schema, prisma db push is a success instead of failing because paymentId field has @id and @unique

Expected behavior

Prisma should report this error “@unique”: Fields that are marked as id should not have an additional" before prisma db push can be successful

Prisma information

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: v14.16.1

Prisma Version

prisma                  : 3.9.2
@prisma/client          : 3.9.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
borngracedcommented, Apr 1, 2022

Ok…sorry, I’ve been away. I’m going to try to reproduce the error and share!

0reactions
janpiocommented, Dec 11, 2022

Fields that are marked as id should not have an additional @unique is not part of our codebase anymore, so we can close this issue. You probably had different versions running locally in some way, which meant that Studio used an older validation than the rest of the tooling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma seed, node says Unique constraint failed on the ...
In the Figures_table you have defined a unique constraint on manufactureID which would mean that each manufacture could only have one figure ...
Read more >
Creating and managing schemas | Cloud Pub/Sub ...
In the Google Cloud console, go to the Pub/Sub schemas page. · Click Create schema. · In the Schema ID field, enter an...
Read more >
Issues that makes DataGrip an odd tool I can't recommend as ...
This is a basic way a database tool should work with result set. ... but ID highlighted as unresolved and UNPIVOT highlighted as...
Read more >
Transactions - Prisma
Creating a team and adding a user should be one atomic operation that succeeds or fails as a whole. To implement atomic writes...
Read more >
dbt Guide - GitLab
These models will be written to a logically named schema in the prep database based on the data source type. For example: Zuora...
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