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

Implement nanoid() #18612

Open
janpio opened this issue Apr 3, 2023 · 8 comments
Open

Implement nanoid() #18612

janpio opened this issue Apr 3, 2023 · 8 comments
Labels
kind/feature A request for a new feature. team/client Issue for team Client. team/schema Issue for team Schema. topic: @default(nanoid()) topic: schema

Comments

@janpio
Copy link
Member

janpio commented Apr 3, 2023

follow up to prisma/prisma-engines#3556

@jkomyno jkomyno added kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. team/client Issue for team Client. labels Apr 5, 2023
@andrictham
Copy link

andrictham commented May 28, 2023

@janpio Is this still planned?

@Piglow19
Copy link

Hello, can we have a update on this feature please ?

@janpio
Copy link
Member Author

janpio commented Jun 12, 2023

Yes, we will do this in the future - but I can not tell you when that will be as we currently do not have this work prioritized.

@ctsstc
Copy link

ctsstc commented Jun 28, 2023

For anyone following the tangled web here's some useful links from other related issues to hold you over until this is implemented into Prisma.

Quick Holdover

Until it's implemented into Prisma it seems the quick route would be to:

  1. Create an empty migration to add the SQL function here: https://github.com/viascom/nanoid-postgres/
  2. Utilize it as a default custom value: https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#override-default-value-behavior-for-supported-types

@janpio janpio changed the title Finish nanoid() Finish nanoid() Aug 29, 2023
@janpio janpio changed the title Finish nanoid() Implement nanoid() Aug 29, 2023
@itzsaga
Copy link

itzsaga commented Dec 6, 2023

My team verified that id String @id @default(nanoid()) works. Looks like it was added in 4.9.0. Pretty sure this can be closed @janpio.

@ctsstc
Copy link

ctsstc commented Dec 7, 2023

@itzsaga confused why that says it was back in January, and #14004 doesn't seem like it provides anything useful from the 4.9.0 release notes, which just sends you on a rabbit hole to #3556 which doesn't solve it and ends in a comment telling you that you can go use it from the source via: prisma/prisma-engines#3556 (comment) linking out to: https://github.com/ai/nanoid

Are you sure someone hasn't already added it to your DB implementation?

@itzsaga
Copy link

itzsaga commented Dec 7, 2023

@ctsstc just double checked and nothing has been done to the DB (spun op a fresh PostgeSQL container and ran against it to be safe, checked functions and what not in case a migration did something). No type errors when defining it:
Screenshot 2023-12-06 at 9 17 40 PM
If I change it something else random there are errors:
Screenshot 2023-12-06 at 9 18 08 PM
So there's some level of type checking what goes in there. I wish I knew the Prisma code base better to dig in and see if I could verify myself. 🤷🏻‍♂️

@itzsaga
Copy link

itzsaga commented Dec 7, 2023

@ctsstc I just ran across #17199 which may be the best place to keep track of the final list of things to be completed before it goes "public".

@janpio janpio added kind/feature A request for a new feature. and removed kind/improvement An improvement to existing feature and code. labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. team/client Issue for team Client. team/schema Issue for team Schema. topic: @default(nanoid()) topic: schema
Projects
None yet
Development

No branches or pull requests

6 participants