Prisma1: One field of the type `User` must be marked as the id field with the `@id` directive.

Created on 26 Apr 2019  ·  19Comments  ·  Source: prisma/prisma1

A brand new project, the generated datamodel.prisma

type User {
  id: ID! @unique
  name: String!
}

When running $prisma deploy to a demo server i get this error

✖ One field of the type `User` must be marked as the id field with the `@id` directive.

Ok so I change id: ID! @id and now it deploys BUT.... now i want to use my Heroku db and server and on deploy..
The field `id` is reserved and has to have the format: id: ID! @unique

🤦‍♂️ Seems like each has a different idea of what to expect with id : ID, got around this with

type User {
  id: ID! @unique
  anyName: ID! @id
  name: String!
}

But it seems a bit foolish to have to have two Id fields?

To Reproduce
https://github.com/andrewcodes404/prisma-id-error

aredeploy bu0-needs-info

Most helpful comment

Had the same problem, but got around it with just a:

type User {
    id: ID! @id
    name: String!
}

All 19 comments

Had the same problem, but got around it with just a:

type User {
    id: ID! @id
    name: String!
}

@andrewcodes404

Can you please share your cli version? The demo server uses the new datamodel format so you will need cli version greater than 1.31 in order to be compatible with the demo server.

What you are getting right now is a mix of old and new datamodel validation warnings which I suspect are caused by mismatching the version of the CLI and server.

ah yes... prisma/1.30.2 (darwin-x64) node-v10.15.0

how do i get to 1.31 i use npm install -g prisma but it will only get me to 1.30?

~try npm install -g [email protected]~

Wait, I checked on npm and somehow only 1.30 is showing up there, we will need to check the CI pipeline

Ok, the tag is on npm(https://www.npmjs.com/package/prisma/v/1.31.1) but somehow on homepage npm is not picking it up. npm install -g [email protected] should work

Thanks for reporting! We just released 1.31.2.

Hi, @timsuchanek. I just tried using 1.31.2 and I'm having issues. The CLI installed fine but once I set it to that version in docker-compose.yml I'm seeing an error.

➜ git:(master) ✗ prisma --version
Prisma CLI version: prisma/1.31.2 (darwin-x64) node-v10.15.3
➜ git:(master) ✗ docker-compose up -d
Pulling prisma (prismagraphql/prisma:1.31.2)...
ERROR: manifest for prismagraphql/prisma:1.31.2 not found

Am I missing something here? Thanks in advance.

_Update: I looked on Docker and can't see a tag for that version._

@darrylyoung

Dockerhub is rate-limiting request(that is what caused the graphcool outage) so try again, using 1.31 in the docker-compose file.

ok great it's working on the demo server... but now when I try and create a prod server with Heroku I get the same error
✖ The field `id` is reserved and has to have the format: id: ID! @unique or id: UUID! @unique.

The Heroku servers are running 1.23.0! how can i get them to run 1.32?

You'll probably tell me to go here https://github.com/prisma/prisma-cloud-feedback/issues/202#issuecomment-414095090
But that is way too much, is there a way in https://app.prisma.io ?

Sorry @andrewcodes404 but that is the way as the server is not hosted by us.

It is the standard process for updating a heroku container deploy.

@pantharshit00 eek.. I have no idea what a docker container image is. How can i downgrade the CLI and Server back to 1.23?

If you downgrade, datamodel 1.1 will not be available.

Please message me on slack(slack.prisma.io). I am @harshit there. I will be happy to help you in this regard.

Had the same problem, but got around it with just a:

type User {
    id: ID! @id
    name: String!
}

I did the same, it works fine. Thank you

Hi, I'm following along the Getting Started > New Database docs, and I'm able to replicate the error, _but only the second time I try_ prisma deploy _and afterwards_.

What happened was, I was playing around with managementApiSecret and so was deleting prisma.yml and datamodel.prisma, then re-doing prisma init --endpoint http://localhost:4466 and finally redeploying.

It was strange that this error only happened after the first time. I tried deleting and recreating the docker images but this error persisted. Of course, adding @id resolved it, but I'm now confused as to why my first attempt was successful in the first place.

This is one did it for me as well 👍

type User {
    id: ID! @id
    name: String!
}

Just met this issue while using prisma CLI installed from hombrew. I think npm should be introduced as more preferred option to install prisma CLI

Had the same problem, but got around it with just a:

type User {
    id: ID! @id
    name: String!
}

Yes, did the trick!

I too had the same problem and did as follows:

type User {
id: ID! @id @unique
name: String!
...
}

Also, had errors with a createdAt field:

...
createdAt: DateTime! @createdAt
}

Hope this helps someone.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MitkoTschimev picture MitkoTschimev  ·  3Comments

sedubois picture sedubois  ·  3Comments

schickling picture schickling  ·  3Comments

thomaswright picture thomaswright  ·  3Comments

ragnorc picture ragnorc  ·  3Comments