[Introspection] Introspect `uuid_generate_v1()` and `uuid_v4()` as database level defaults
See original GitHub issueVersion: 2.0.0-preview022
Query
CREATE TABLE "public"."User" (
id UUID PRIMARY KEY DEFAULT uuid_generate_v1(),
name VARCHAR(255) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL
);
Excepted
model User {
email String @unique
id String @id @default(uuid())
name String @unique
password String
}
Result
model User {
email String @unique
id String @id
name String @unique
password String
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:6 (4 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m also interested in it.
UUID also have special type in Postgres tables which makes sure that it’s valid uuid. Currently it’s just a string.
Something like this would be useful. Also, UUID has various version, which can be very important, especially if someone with legacy data is migrating to prisma.
Right now I’m validating those server side in node, but having native, database validation is always better.
They are now represented as
@default(dbgenerated("...")). Please open a new issue if that doesn’t work for your use case.