Prisma1: [RFC] Datamodel v1.1

Created on 1 Nov 2018  ยท  3Comments  ยท  Source: prisma/prisma1

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.

Parts

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

Directive list

Type Level

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

Field Level

  1. @id
  2. @createdAt
  3. @updatedAt
  4. @default
  5. @db
  6. @scalarList
  7. @sequence
  8. @relation
  9. @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.
aremigrations aredatamodel rf1-draft

Most helpful comment

Will datamodel v1.1 allow for us to add custom scalars to Prisma datamodel? Like,

scalar IP

type MyType {
  ip: IP!
}

All 3 comments

Will datamodel v1.1 allow for us to add custom scalars to Prisma datamodel? Like,

scalar IP

type MyType {
  ip: IP!
}

The datamodel v1.1 is ready to be tested ๐ŸŽ‰ You can find all instructions how to get started in this GitHub repo.

@nikolasburk I have installed the latest beta 1.31.0-beta.1 just to test introspect

I followed your instructions in this

After running this

prisma introspect --prototype -e .env
prisma deploy -e .env

I got the following errors

AmAdmin
โœ– The value 0 is not a valid default for fields of type Boolean.

AmAgreement
โœ– The value 0 is not a valid default for fields of type Boolean.

AmBillingPlan
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.

AmButton
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.

AmCouponBatch
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.

AmEmailTemplate
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 1 is not a valid default for fields of type Boolean.

AmInvoice
โœ– The value 0 is not a valid default for fields of type Boolean.

AmInvoiceItem
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.

AmInvoiceLog
โœ– The value 0 is not a valid default for fields of type Boolean.

AmProduct
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.

AmProductOption
โœ– The value 0 is not a valid default for fields of type Boolean.

AmProductUpgrade
โœ– The value 0 is not a valid default for fields of type Boolean.

AmResourceAccess
โœ– The value 0 is not a valid default for fields of type Boolean.

AmUser
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 1 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.
โœ– The value 0 is not a valid default for fields of type Boolean.

AmUserStatus
โœ– The value 0 is not a valid default for fields of type Boolean.

AmAccessCachefnEnum
โœ– The enum type AmAccessCachefnEnum contains invalid enum values. The first character of each value must be an uppercase letter.

AmAccessCachestatusEnum
โœ– The enum type AmAccessCachestatusEnum contains invalid enum values. The first character of each value must be an uppercase letter.

AmCountrystatusEnum
โœ– The enum type AmCountrystatusEnum contains invalid enum values. The first character of each value must be an uppercase letter.

AmCouponBatchdiscountTypeEnum
โœ– The enum type AmCouponBatchdiscountTypeEnum contains invalid enum values. The first character of each value must be an uppercase letter.

AmEmailTemplateformatEnum
โœ– The enum type AmEmailTemplateformatEnum contains invalid enum values. The first character of each value must be an uppercase letter.

AmResourceAccessfnEnum
โœ– The enum type AmResourceAccessfnEnum contains invalid enum values. The first character of each value must be an uppercase letter.

AmStatestatusEnum
โœ– The enum type AmStatestatusEnum contains invalid enum values. The first character of each value must be an uppercase letter.

BTW : I'm using mysql


UPDATE :
after fixing the errors above manually and ran prisma deploy
I got this error
"message":"Bad(InvalidValueForScalarType("CURRENT_TIMESTAMP",DateTime)).get"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thomaswright picture thomaswright  ยท  3Comments

nikolasburk picture nikolasburk  ยท  3Comments

marktani picture marktani  ยท  3Comments

ragnorc picture ragnorc  ยท  3Comments

Fi1osof picture Fi1osof  ยท  3Comments