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

[RFC] Datamodel v2 #3408

mavilein opened this Issue Nov 1, 2018 · 0 comments


None yet
2 participants

mavilein commented Nov 1, 2018

This spec acts as the central place for all discussions around data model syntax. It contains new syntax for existing features as well as missing features.

timeline: Currently we do not have a timeline yet for those features. First we want to settle on a spec together with the community. Then we will start to plan the actual implementation of those features.

handling of breaking changes: The spec contains some breaking changes. We are aware that this would be a huge burden for existing projects. Therefore we plan to offer an easy way to migrate existing projects to the new syntax, e.g. by rewriting the data model on version upgrade.

The goals for this spec are:

  • It should advance our data model syntax in order to support more databases. Concretely it contains the syntax for supporting relational and document databases.
  • It should precisely define valid and invalid syntax in order to facilitate comprehensive data model validations.
  • It should propose syntax for features we have not been able to build yet. This will be the foundation to actually implement those features.
  • It aims at unifying the behaviour of active and passive connectors (based on the migrations setting in the server config). This means that Prisma will provide defaults for many things but is still configurable through the use of directives. This will enable seamless switching between the active and passive modes.


For better readability the spec has been split into multiple parts:

Directive list

Type Level

  1. @db
  2. @plural
  3. @linkTable
  4. @embedded
  5. @indexes
  6. @discriminator

Field Level

  1. @id
  2. @createdAt
  3. @updatedAt
  4. @default
  5. @db
  6. @scalarList
  7. @constraint
  8. @sequence
  9. @immutable
  10. @relation
  11. @unique

Interface Level

  1. @inheritance

Glossary of terms used in the spec

  • Relation Link: a relation link is the concrete instance where two nodes gets linked. In SQL this could be a row in a relation table or foreign key column in a table for a type. In Mongo these are fields that contain ids to other documents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment