question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Introspection] Introspect `uuid_generate_v1()` and `uuid_v4()` as database level defaults

See original GitHub issue

Version: 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pie6kcommented, Jun 27, 2020

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.

model User {
  email    String @unique
  id       UUID @default(uuid_v4()) @id
  name     String @unique
}

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.

0reactions
tomhoulecommented, May 6, 2021

They are now represented as @default(dbgenerated("...")). Please open a new issue if that doesn’t work for your use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found