Skip to content
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

Add support for Prisma uuid(7) #196

Open
micobarac opened this issue Aug 30, 2024 · 5 comments
Open

Add support for Prisma uuid(7) #196

micobarac opened this issue Aug 30, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@micobarac
Copy link

micobarac commented Aug 30, 2024

Feature request

Is your feature request related to a problem? Please describe.

Currently, Prisma uuid(7) isn't supported.

model Agency {
  id         String   @id @default(uuid(7)) @db.Char(36)
  name       String   @unique
  active     Boolean  @default(true)
  createdAt  DateTime @default(now()) @map("created_at")
  updatedAt  DateTime @updatedAt @map("updated_at")
  users      User[]

  @@map("agency")
}
~/Sites/nestjs (master)$ npx @snaplet/seed init prisma/seed

Welcome to @snaplet/seed! Snaplet Seed populates your database with realistic, production-like mock data ✨

✔ Installed the dependencies: `@snaplet/copycat`

✔ Seed configuration saved to file:///Users/user/Sites/nestjs/prisma/seed/seed.config.ts

✖ Database analysis failed
GetConfigError: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Error parsing attribute "@default": The `uuid` function does not take any argument. Consider changing this default to `uuid()`.
  -->  schema.prisma:11
   | 
10 | model Agency {
11 |   id         String   @id @default(uuid(7)) @db.Char(36)

Describe the solution you'd like

I'd like the uuid version 7 support.

Describe alternatives you've considered

I don't see a way around this.

Additional context

Installed dependencies:

"@nestjs/common": "^10.4.1",
"@nestjs/core": "^10.4.1",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^10.4.1",
"@nestjs/swagger": "^7.4.0",
"@nestjs/typeorm": "^10.0.2",
"prisma": "^5.19.0"
"@prisma/client": "^5.19.0",
"@nestjs/cli": "^10.4.4",
"@nestjs/schematics": "^10.1.4",
"@nestjs/testing": "^10.4.1"
@micobarac micobarac added the enhancement New feature or request label Aug 30, 2024
@peterp
Copy link
Collaborator

peterp commented Aug 31, 2024

@micobarac Interesting, is this fix simply updating the Prisma dependency used in Snaplet?

@micobarac
Copy link
Author

micobarac commented Sep 2, 2024

@peterp I was considering using Snaplet Seed for seeding default data in NestJS experimental project via Prisma. Prisma has a built-in support for UUID v7. UUID v7 has a numerous benefits over older versions. The problem is, Snaplet Seed doesn't expect a parameter inside uuid(): id String @id @default(uuid(7)) @db.Char(36).

Add support for UUIDv7

@peterp
Copy link
Collaborator

peterp commented Sep 2, 2024

@micobarac Understood, I think this may be because the Prisma version that Snaplet Seed is using is a bit outdated. Could you update our Prisma dependencies and see if it allows uuid() to take a parameter?

@micobarac
Copy link
Author

Thanks. I will give it a try.

@djshubs
Copy link

djshubs commented Sep 23, 2024

@micobarac -- see this comment. #201 (comment)

I was able to get typedSql working. If that works, I presume you will be able to get uuid() working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants