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

Finish the implementation of @default(nanoid()) #17199

Open
1 of 9 tasks
tomhoule opened this issue Jan 9, 2023 · 7 comments
Open
1 of 9 tasks

Finish the implementation of @default(nanoid()) #17199

tomhoule opened this issue Jan 9, 2023 · 7 comments
Labels
kind/feature A request for a new feature. team/schema Issue for team Schema. topic: @default(nanoid()) topic: default
Milestone

Comments

@tomhoule
Copy link
Contributor

tomhoule commented Jan 9, 2023

See prisma/prisma-engines#3556 for context.

The missing pieces we identified:

Once these tasks are done, we need to:

Note: an improvement has been identified but is not planned for now -> #17294

@tomhoule tomhoule added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. process/candidate team/schema Issue for team Schema. labels Jan 9, 2023
@Jolg42 Jolg42 added kind/feature A request for a new feature. topic: default and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. labels Jan 9, 2023
@Jolg42
Copy link
Member

Jolg42 commented Jan 9, 2023

Note: there is a docs issue at prisma/docs#4363
And PR prisma/docs#4367

@Jolg42
Copy link
Member

Jolg42 commented Jan 9, 2023

For Language-tools 2 files need to be modified, basically copy what we do for cuid and rename to nanoid
https://github.com/search?q=repo%3Aprisma%2Flanguage-tools%20cuid&type=code

@rintaun
Copy link

rintaun commented Jan 9, 2023

@tomhoule For clarification, when you say

special handling of prisma-level defaults re: warnings

are you talking about when you run prisma db pull it emits warnings saying These models were enriched with ... information taken from the previous Prisma schema-type messages?

If so, I'm not sure such warnings are actually emitted for cuid() and uuid() defaults right now, though I may be wrong. That's not to say I don't think it's a good idea, though.

@Jolg42
Copy link
Member

Jolg42 commented Jan 9, 2023

Note: @tomhoule thinks he can point you to the functionality in the sql-destructive-change-checker you need to make work for this.
But he is quite busy today and would need to dive into the implementation again for the details and write a bunch of tests for diffing schemas with these defaults. They will be broken, and they will have to be fixed.

@rintaun
Copy link

rintaun commented Jan 10, 2023

I think I see where you're talking about (warnings.rs and scalar_field.rs seem relevant, among others in that call chain), but I don't see any warnings related to cuid() or uuid() except regarding Prisma 1.

@tomhoule
Copy link
Contributor Author

For the warnings: it's about migration warnings in rather than introspection warnings, I'd follow the code around https://github.com/rintaun/prisma-engines/blob/c71fd52daf0c7a10c154d02e2a6ef791e4a792c3/migration-engine/connectors/sql-migration-connector/src/database_schema.rs#L8

For the implementation: adding a simple test with a schema with a nanoid default in https://github.com/rintaun/prisma-engines/tree/c71fd52daf0c7a10c154d02e2a6ef791e4a792c3/migration-engine/migration-engine-tests/tests/single_migration_tests should make the problem with migration generation visible.

@Jolg42 Jolg42 added this to the 4.9.0 milestone Jan 10, 2023
@Jolg42 Jolg42 modified the milestones: 4.9.0, 4.10.0 Jan 17, 2023
Jolg42 added a commit to prisma/language-tools that referenced this issue Jan 27, 2023
Part of: prisma/prisma#17199

Note: we want to wait until all the work is done (see issue) before merging this.
@Jolg42
Copy link
Member

Jolg42 commented Jan 27, 2023

@rintaun I updated the TODO list at the top.

Did you have time to check for Migrate support and what @tomhoule mentioned? Do you need help?

Once the TODO tasks are complete in the description, we will officially add it as supported by Prisma in the next release.

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/schema Issue for team Schema. topic: @default(nanoid()) topic: default
Projects
None yet
Development

No branches or pull requests

4 participants