Skip to content

technology-studio/prisma-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prisma schema

Prisma schema processor

Cli commands

yarn prisma-schema --help

process

based on @smcelhinney's smcelhinney/prisma-merge-schema

Decorators

  • @attribute-override
  • @attribute-remove
  • @auto-delete
  • @extend
  • @inherits
  • @import
  • @abstract

Api reference

  • � TBD �

Example

Following files

Header

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x"]
  // previewFeatures = []
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Abstract entities

model BaseModel { // @abstract
  id                String      @id @default(cuid())
  createdDateTime   DateTime    @default(now())
  updatedDateTime   DateTime    @updatedAt
  deletedDateTime   DateTime    @default("1970-01-01T00:00:00-00:00")
}

Entity inheritance

// @import './base.template.prisma'

enum Platform {
  ANDROID
  IOS
  WEB
  WINDOWS
}

model Application { // @inherits BaseModel
  clientKey         String
  clientSecret      String
  platform          Platform
}

Entity extending

model Application { // @extend
  version           String
}

model Application { // @extend
  name           String
}

Entity attribute override

model Application { // @attribute-override
  clientSecret         Int
}

Entity attribute removal

model Application { // @attribute-remove
  clientKey         Int
}

Main source template

// @import './header.template.prisma'
// @import './inherit.template.prisma'
// @import './extend.template.prisma'
// @import './attribute-override.template.prisma'
// @import './attribute-remove.template.prisma'

will produce

Autogenerated prisma schema

// This file was generated by @txo/prisma-schema (https://www.npmjs.com/package/@txo/prisma-schema)
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x"]
  // previewFeatures = []
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

enum Platform {
  ANDROID
  IOS
  WEB
  WINDOWS
}

model Application {
  id              String   @id @default(cuid())
  createdDateTime DateTime @default(now())
  updatedDateTime DateTime @updatedAt
  deletedDateTime DateTime @default("1970-01-01T00:00:00-00:00")
  clientSecret    Int
  platform        Platform
  version         String
  name            String
}