Coder Social home page Coder Social logo

dznbk / prisma-erd-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from keonik/prisma-erd-generator

0.0 0.0 0.0 2.42 MB

Generate an ER Diagram based on your Prisma schema every time you run npx prisma generate

Home Page: https://www.npmjs.com/package/prisma-erd-generator

License: MIT License

Shell 1.35% JavaScript 18.04% TypeScript 80.61%

prisma-erd-generator's Introduction

Prisma Entity Relationship Diagram Generator

All Contributors

Prisma generator to create an ER Diagram every time you generate your prisma client.

Like this tool? @Skn0tt started this effort with his web app ER diagram generator

npm i -D prisma-erd-generator @mermaid-js/mermaid-cli
# or
yarn add -D prisma-erd-generator @mermaid-js/mermaid-cli

Add to your schema.prisma

generator erd {
  provider = "prisma-erd-generator"
}

Run the generator

npx prisma generate

Example ER Diagram

Versions

  • Prisma >= 4 use 1.x.x
  • Prisma <4 use 0.11.x

Options

Additional configuration

Output

Change output type and location

Usage

generator erd {
  provider = "prisma-erd-generator"
  output = "../ERD.svg"
}

Extensions

  • svg (default: ./prisma/ERD.svg)
  • png
  • pdf
  • md

Theme

Theme selection

Usage

generator erd {
  provider = "prisma-erd-generator"
  theme = "forest"
}

Options

  • default (default)
  • forest
  • dark
  • neutral

Disabled

You won't always need to generate a new ER diagram. To disabled running this generator just add an environment variable to the environment running prisma generate.

DISABLE_ERD=true

Debugging

If you have issues with generating or outputting an ERD as expected, you may benefit from seeing output of the steps to making your ERD. Enable debugging by either adding the following environment variable

ERD_DEBUG=true

or adding in the debug configuration key set to true

generator erd {
  provider = "prisma-erd-generator"
  erdDebug = true
}

and re-running prisma generate. You should see a directory and files created labeling the steps to create an ER diagram under prisma/debug.

Please use these files as part of opening an issue if you run into problems.

Table only mode

Table mode only draws your models and skips the attributes and columns associated with your table. This feature is helpful for when you have lots of table columns and they are less helpful than seeing the tables and their relationships

generator erd {
  provider = "prisma-erd-generator"
  tableOnly = true
}

Include relation from field

By default this module skips relation fields in the result diagram. For example fields userId and productId will not be generated from this prisma schema.

model User {
  id            String         @id
  email         String
  favoriteProducts  FavoriteProducts[]
}


model Product {
  id              String        @id
  title           String
  inFavorites  FavoriteProducts[]
}

model FavoriteProducts {
  userId      String
  user        User    @relation(fields: [userId], references: [id])
  productId   String
  product     Product @relation(fields: [productId], references: [id])

  @@id([userId, productId])
}

It can be useful to show them when working with RDBMS. To show them use includeRelationFromFields = true

generator erd {
  provider = "prisma-erd-generator"
  includeRelationFromFields = true
}

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


John Fay

๐Ÿšง ๐Ÿ’ป ๐Ÿค” ๐Ÿ›

Jonas Strassel

๐Ÿ› ๐Ÿ’ป

Steve Gray

๐Ÿ’ป ๐Ÿค”

Jason Abbott

๐Ÿ› ๐Ÿ’ป

Manuel Maute

๐Ÿ› ๐Ÿ’ป

James Homer

๐Ÿ’ป

Jan Piotrowski

๐Ÿ› ๐Ÿ’ป ๐Ÿ‘€

Luke Evers

๐Ÿ’ป

rikuyam

๐Ÿ’ป

Francis Manansala

๐Ÿ›

Vitalii Yarmus

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

prisma-erd-generator's People

Contributors

keonik avatar dependabot[bot] avatar janpio avatar allcontributors[bot] avatar jason-abbott avatar boredland avatar lukevers avatar jsbrain avatar heystevegray avatar vitalii4as avatar ripry avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.