Git Product home page Git Product logo

prisma-erd's Introduction

prisma-erd's People

Contributors

7ganam avatar allcontributors[bot] avatar skn0tt avatar zeko369 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

prisma-erd's Issues

Schemas to break the tool

Hey @Skn0tt, nice tool - happy to see something like this from our community at Prisma!

If you see some FUNCTION_INVOCATION_FAILED in your server/function logs, that would be me trying out some of our Prisma internal testing schemas. I thought I might share them with you.

Here is one of our monsters:

bench.schema.prisma.txt

This is a pretty simple. industry standard one:

model Album {
  AlbumId  Int     @id @default(autoincrement())
  Title    String  @db.VarChar(160)
  ArtistId Int
  Artist   Artist  @relation(fields: [ArtistId], references: [ArtistId])
  Track    Track[]

  @@index([ArtistId], name: "IFK_AlbumArtistId")
}

model Artist {
  ArtistId Int     @id @default(autoincrement())
  Name     String? @db.VarChar(120)
  Album    Album[]
}

model Customer {
  CustomerId   Int       @id @default(autoincrement())
  FirstName    String    @db.VarChar(40)
  LastName     String    @db.VarChar(20)
  Company      String?   @db.VarChar(80)
  Address      String?   @db.VarChar(70)
  City         String?   @db.VarChar(40)
  State        String?   @db.VarChar(40)
  Country      String?   @db.VarChar(40)
  PostalCode   String?   @db.VarChar(10)
  Phone        String?   @db.VarChar(24)
  Fax          String?   @db.VarChar(24)
  Email        String    @db.VarChar(60)
  SupportRepId Int?
  Employee     Employee? @relation(fields: [SupportRepId], references: [EmployeeId])
  Invoice      Invoice[]

  @@index([SupportRepId], name: "IFK_CustomerSupportRepId")
}

model Employee {
  EmployeeId     Int        @id @default(autoincrement())
  LastName       String     @db.VarChar(20)
  FirstName      String     @db.VarChar(20)
  Title          String?    @db.VarChar(30)
  ReportsTo      Int?
  BirthDate      DateTime?  @db.DateTime(0)
  HireDate       DateTime?  @db.DateTime(0)
  Address        String?    @db.VarChar(70)
  City           String?    @db.VarChar(40)
  State          String?    @db.VarChar(40)
  Country        String?    @db.VarChar(40)
  PostalCode     String?    @db.VarChar(10)
  Phone          String?    @db.VarChar(24)
  Fax            String?    @db.VarChar(24)
  Email          String?    @db.VarChar(60)
  Employee       Employee?  @relation("EmployeeToEmployee_ReportsTo", fields: [ReportsTo], references: [EmployeeId])
  Customer       Customer[]
  other_Employee Employee[] @relation("EmployeeToEmployee_ReportsTo")

  @@index([ReportsTo], name: "IFK_EmployeeReportsTo")
}

model Genre {
  GenreId Int     @id @default(autoincrement())
  Name    String? @db.VarChar(120)
  Track   Track[]
}

model Invoice {
  InvoiceId         Int           @id @default(autoincrement())
  CustomerId        Int
  InvoiceDate       DateTime      @db.DateTime(0)
  BillingAddress    String?       @db.VarChar(70)
  BillingCity       String?       @db.VarChar(40)
  BillingState      String?       @db.VarChar(40)
  BillingCountry    String?       @db.VarChar(40)
  BillingPostalCode String?       @db.VarChar(10)
  Total             Decimal       @db.Decimal(10, 2)
  Customer          Customer      @relation(fields: [CustomerId], references: [CustomerId])
  InvoiceLine       InvoiceLine[]

  @@index([CustomerId], name: "IFK_InvoiceCustomerId")
}

model InvoiceLine {
  InvoiceLineId Int     @id @default(autoincrement())
  InvoiceId     Int
  TrackId       Int
  UnitPrice     Decimal @db.Decimal(10, 2)
  Quantity      Int
  Invoice       Invoice @relation(fields: [InvoiceId], references: [InvoiceId])
  Track         Track   @relation(fields: [TrackId], references: [TrackId])

  @@index([InvoiceId], name: "IFK_InvoiceLineInvoiceId")
  @@index([TrackId], name: "IFK_InvoiceLineTrackId")
}

model MediaType {
  MediaTypeId Int     @id @default(autoincrement())
  Name        String? @db.VarChar(120)
  Track       Track[]
}

model Playlist {
  PlaylistId    Int             @id @default(autoincrement())
  Name          String?         @db.VarChar(120)
  PlaylistTrack PlaylistTrack[]
}

model PlaylistTrack {
  PlaylistId Int
  TrackId    Int
  Playlist   Playlist @relation(fields: [PlaylistId], references: [PlaylistId])
  Track      Track    @relation(fields: [TrackId], references: [TrackId])

  @@id([PlaylistId, TrackId])
  @@index([TrackId], name: "IFK_PlaylistTrackTrackId")
}

model Track {
  TrackId       Int             @id @default(autoincrement())
  Name          String          @db.VarChar(200)
  AlbumId       Int?
  MediaTypeId   Int
  GenreId       Int?
  Composer      String?         @db.VarChar(220)
  Milliseconds  Int
  Bytes         Int?
  UnitPrice     Decimal         @db.Decimal(10, 2)
  Album         Album?          @relation(fields: [AlbumId], references: [AlbumId])
  Genre         Genre?          @relation(fields: [GenreId], references: [GenreId])
  MediaType     MediaType       @relation(fields: [MediaTypeId], references: [MediaTypeId])
  InvoiceLine   InvoiceLine[]
  PlaylistTrack PlaylistTrack[]

  @@index([AlbumId], name: "IFK_TrackAlbumId")
  @@index([GenreId], name: "IFK_TrackGenreId")
  @@index([MediaTypeId], name: "IFK_TrackMediaTypeId")
}

Let me know if you need more, both huge or small, to test specific things - happy to help out here.

Support mongodb?

I just tested this shema:

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

model User {
  id              String                 @id @default(auto()) @map("_id") @db.ObjectId
  name            String
}

It return error:

error: Error parsing attribute \"@default\": The function auto is not a known function.

Does this support mongo?
Sorry for my bad english, btw.

wrong result -> (zero or one) is shown as (one and only one)

I have the following schema where an Incedent should have zero to one department but it is shown as one and only one departement

datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}
model Incident {
  id          String   @id @default(uuid())

  assignedDepartment Department? @relation(fields: [assignedDepartmentId], references: [id])
  assignedDepartmentId String? 

// optional to allow for an incident to have no assigned department --- not unique to allow for multiple incidents to be assigned to the same department
}

model Department {
  id        String   @id @default(uuid())

  assignedIncidents Incident[]
}

image

Support implicit Many to Many relationships

I noticed this tool does not show implicit Many to Many relationships. Any plans to support this?

For example, the following schema:

model Post {
  id         Int        @id @default(autoincrement())
  title      String
  categories Category[]
}

model Category {
  id    Int    @id @default(autoincrement())
  name  String
  posts Post[]
}

Should result in a diagram with an M:N relationship between Post and Category, but currently it just shows 2 tables.

prisma-erd

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.