Hi everyone. Does anybody know how to create numer...
# orm-help
f
Hi everyone. Does anybody know how to create numeric IDs that increase 1 by 1 with the new data model? I’ve tried but failed, perhaps I’m doing it wrong.
h
You mean a sequence? Just set the allocationSize to 1 to remove gaps between IDs
n
haha I was just about to ask a similar question. Is there a way to use sequence on fields that are not IDs?
I don't actually see anything in the docs about sequence 😕
b
I think Prisma only supports sequence strategy for id fields at this moment. For non IDs fields, you can add sequences to columns that represents your fields in data model, I haven't tried so I'm not sure it will works or not.
👍 1
h
yes, you will need to mark the field as an ID in order to use the sequence directive
n
Thanks all, that makes sense
f
@Harshit @bkstorm Is this correct?
Copy code
id: Int! @id(strategy: SEQUENCE)
    @sequence(name: "AtomicRefNumber", initialValue: 10000, allocationSize: 1)
There must be some issue there because it just throws error if I do that (testing in demo servers).
b
@Fran Dios It's correct. Can you show the error logs?
f
@bkstorm Unfortunately I can’t see the error in the demo server: It throws
Whoops. Looks like an internal server error. Search your server logs for request ID: us1:cjumv2n334dmk0b12fony61sx"
when I try to create a instance of that type. There’s more information in this issue: https://github.com/prisma/prisma/issues/4412