-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ULID #13679
Comments
It would be great to see this feature supported! Since ULID is designed to be the same 128-bits as UUID it should work with the underlying database type, but using this means Prisma throws the error because it is validating the string length which is only 26 characters for ULID. From some further research into this however it seems that Postgres itself doesn't really support ULID as a datatype yet and it's difficult to achieve. Maybe something to consider for the future if this does ever become a feature. |
I've found this thread as my company uses I've asked about |
In postgres you can create function to generate ULID (uuid v7 or uuid v8) https://gist.github.com/kjmph/5bd772b2c2df145aa645b837da7eca74 |
@matus-sabo that's cool, but it's UUID, not ULID. |
I am the author of https://github.com/pksunkara/pgx_ulid and I would be willing to implement this. @janpio and prima people, do I have the go-ahead? |
What exactly is even needed here if there is a PostgreSQL extension? |
But |
Ah, I see that the extension also adds a new Currently Prisma does not offer a way for extensions to add native types. |
Yes, a generated value can only be stored in such an
Yup, which is why I was offering to create a native type |
|
I guess the only way to solve this would be use a custom type as specified in #5039? But there's nothing happening on that. |
I could well be wrong, but referring to previous comment, if ULID is 128-bits can it not just be stored in a standard UUID column? |
It is actually stored in the same format, but since it needs to be read differently, that is why a new type is needed. |
Are ULIDs still needed now that v7 UUIDs are coming into the spec? Should probably just use that. |
I'm linking #24079 here, as it aims to address the same problem in a slightly different way. |
Problem
From the ULID spec.
The Lexicographically sortability would especially be useful for cursor-based pagination which requires sorting by a unique, sequential column.
Suggested solution
Support ULID in the prisma schema, by defining:
@db.Ulid
The text was updated successfully, but these errors were encountered: