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

[Introspection] Identify Prisma 1 Id defaults #2499

Closed
divyenduz opened this issue May 18, 2020 · 1 comment · Fixed by prisma/prisma-engines#763
Closed

[Introspection] Identify Prisma 1 Id defaults #2499

divyenduz opened this issue May 18, 2020 · 1 comment · Fixed by prisma/prisma-engines#763
Labels
kind/improvement An improvement to existing feature and code. tech/engines Issue for tech Engines. topic: introspection topic: prisma1
Milestone

Comments

@divyenduz
Copy link
Contributor

divyenduz commented May 18, 2020

Problem

Prisma 1 IDs are introspected as Strings without a default/@default.

Suggested solution

Introspection can be improved following this logic:

  1. Is it a Prisma1 or Prisma11 classified database schema?
  2. Is there a primary key column of type char(25) or char(36)?
  3. If yes, apply the following default:
    • char(25) -> @default(cuid())
    • char(36) -> @default(uuid())

Additional context

@divyenduz divyenduz added topic: introspection topic: prisma1 kind/improvement An improvement to existing feature and code. labels May 18, 2020
@janpio janpio added tech/engines Issue for tech Engines. process/candidate labels May 19, 2020
@janpio janpio changed the title Identify Prisma 1 ID types in introspection Identify Prisma 1 Id defaults May 25, 2020
@janpio janpio changed the title Identify Prisma 1 Id defaults [Introspection]Identify Prisma 1 Id defaults May 25, 2020
@janpio janpio changed the title [Introspection]Identify Prisma 1 Id defaults [Introspection] Identify Prisma 1 Id defaults May 25, 2020
@do4gr
Copy link
Member

do4gr commented May 25, 2020

Additionally we should generat warnings for cases where we do such an inference. Since this is based upon us recognizing the schema as P1 migrated and this itself is only a heuristic.

We would therefore render the defaults but emit warnings at the same time, so the user knows these are not based on information in the SQL schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. tech/engines Issue for tech Engines. topic: introspection topic: prisma1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants