Custom UUID
When declaring my schema, I would like to provide a custom UUID generator for the id column. At the moment, it's just int autoincrement or
serial
from drizzle. Is there a way to replace this with something like ulid
with a prefix?6 Replies
looks like as for now the only option is to provide id on each insert
Yeah, I just define the column as a varchar and generate the id myself and insert it.
Depending on your DB, if you are storing UUIDs (and even ULIDs) then you should really store them as
BINARY(16)
rather than varchar.
ULIDs and UUIDs are binary compatible (128-bit)Right, I went with this option as well
Noted. Thanks!
Just added support for it in 0.28.3
https://github.com/drizzle-team/drizzle-orm/releases/tag/0.28.3
GitHub
Release 0.28.3 · drizzle-team/drizzle-orm
🎉 Added SQLite simplified query API
🎉 Added .$defaultFn() / .$default() methods to column builders
You can specify any logic and any implementation for a function like cuid() for runtime defaul...
Note there may be some issues with types for esm projects, which we are fixing now and goint to release fixes in 0.28.4