{"id":13475620,"url":"https://github.com/notiz-dev/prisma-dbml-generator","last_synced_at":"2025-05-15T08:03:46.891Z","repository":{"id":37843216,"uuid":"288564876","full_name":"notiz-dev/prisma-dbml-generator","owner":"notiz-dev","description":"Prisma DBML Generator","archived":false,"fork":false,"pushed_at":"2024-02-15T18:26:38.000Z","size":938,"stargazers_count":715,"open_issues_count":17,"forks_count":38,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T19:15:53.022Z","etag":null,"topics":["dbml","prisma"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notiz-dev.png","metadata":{"funding":{"github":"notiz-dev","patreon":"notiz_dev"},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-18T21:08:15.000Z","updated_at":"2025-05-04T14:42:11.000Z","dependencies_parsed_at":"2023-01-29T02:45:26.604Z","dependency_job_id":"b82270e1-dcb2-4cb8-8ac4-d46db0e78bd9","html_url":"https://github.com/notiz-dev/prisma-dbml-generator","commit_stats":{"total_commits":155,"total_committers":9,"mean_commits":17.22222222222222,"dds":0.4838709677419355,"last_synced_commit":"752f89cf40257a9698913294b38843ac742f8345"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notiz-dev%2Fprisma-dbml-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notiz-dev%2Fprisma-dbml-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notiz-dev%2Fprisma-dbml-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notiz-dev%2Fprisma-dbml-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notiz-dev","download_url":"https://codeload.github.com/notiz-dev/prisma-dbml-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301420,"owners_count":22047901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbml","prisma"],"created_at":"2024-07-31T16:01:21.967Z","updated_at":"2025-05-15T08:03:46.804Z","avatar_url":"https://github.com/notiz-dev.png","language":"TypeScript","funding_links":["https://github.com/sponsors/notiz-dev","https://patreon.com/notiz_dev"],"categories":["TypeScript",":safety_vest: Community Prisma Tools"],"sub_categories":[":gear: Schema Visualization Tools"],"readme":"\u003ch1 align=\"center\"\u003eprisma-dbml-generator\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\nAutomatically generate a \u003ca href=\"https://www.dbml.org/home\"\u003eDBML\u003c/a\u003e schema from your \u003ca href=\"https://github.com/prisma/prisma\"\u003ePrisma\u003c/a\u003e Schema.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/notiz-dev/prisma-dbml-generator/actions/workflows/node.js.yml\" target=\"_blank\" rel=\"noopener\"\u003e\n    \u003cimg src=\"https://github.com/notiz-dev/prisma-dbml-generator/actions/workflows/node.js.yml/badge.svg\"alt=\"Build Status\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/prisma-dbml-generator\" target=\"_blank\" rel=\"noopener\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/prisma-dbml-generator.svg\" alt=\"Total Downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/prisma-dbml-generator\" target=\"_blank\" rel=\"noopener\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/prisma-dbml-generator.svg\" alt=\"npm package\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/notiz-dev/prisma-dbml-generator/blob/main/LICENSE\" target=\"_blank\" rel=\"noopener\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/prisma-dbml-generator.svg\" alt=\"License\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nUpdates every time `npx prisma generate` runs. Use [dbdiagram.io](https://dbdiagram.io/home) to visualize your `dbml` files as Entity-Relationship Diagram:\n\n![DB Diagram](https://raw.githubusercontent.com/notiz-dev/prisma-dbml-generator/main/dbdiagram.png)\n\n## Getting started\n\n| Prisma   | prisma-dbml-generator                                                            |\n| -------- | -------------------------------------------------------------------------------- |\n| \u003e=2.29.0 |  [0.7.0](https://github.com/notiz-dev/prisma-dbml-generator/releases/tag/v0.7.0) |\n|  \u003c2.29.0 |  [0.6.0](https://github.com/notiz-dev/prisma-dbml-generator/releases/tag/v0.6.0) |\n\n1. Install this generator:\n\n```bash\nnpm install -D prisma-dbml-generator\n```\n\n2. Add the generator to the `schema.prisma`\n\n```prisma\ngenerator dbml {\n  provider = \"prisma-dbml-generator\"\n}\n```\n\n3. Running `npx prisma generate` for the following [schema.prisma](https://github.com/notiz-dev/prisma-dbml-generator/blob/main/prisma/schema.prisma)\n\n```prisma\nmodel User {\n  id        Int      @id @default(autoincrement())\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  email     String   @unique\n  name      String?\n  posts     Post[]\n  profile   Profile?\n  /// user role\n  role      Role     @default(USER)\n}\n\n/// User profile\nmodel Profile {\n  id     Int     @default(autoincrement()) @id\n  bio    String?\n  user   User    @relation(fields: [userId], references: [id])\n  userId Int     @unique\n}\n\nmodel Post {\n  id         Int        @id @default(autoincrement())\n  title      String     @default(\"\")\n  content    String?\n  published  Boolean    @default(false)\n  author     User?      @relation(fields: [authorId], references: [id])\n  authorId   Int?\n  categories Category[]\n}\n\nmodel Category {\n  id    Int    @id @default(autoincrement())\n  name  String\n  posts Post[]\n}\n\n/// user role\nenum Role {\n  ADMIN /// allowed to do everything\n  USER\n}\n```\n\ngenerates the following [schema.dbml](https://github.com/notiz-dev/prisma-dbml-generator/blob/main/prisma/dbml/schema.dbml) to `prisma/dbml`\n\n```dbml\n//// ------------------------------------------------------\n//// THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)\n//// ------------------------------------------------------\n\nTable User {\n  id Int [pk, increment]\n  createdAt DateTime [default: `now()`, not null]\n  updatedAt DateTime [not null]\n  email String [unique, not null]\n  name String\n  posts Post\n  profile Profile\n  role Role [not null, default: 'USER', note: 'user role']\n}\n\nTable Profile {\n  id Int [pk, increment]\n  bio String\n  user User [not null]\n  userId Int [unique, not null]\n\n  Note: 'User profile'\n}\n\nTable Post {\n  id Int [pk, increment]\n  title String [not null, default: '']\n  content String\n  published Boolean [not null, default: false]\n  author User\n  authorId Int\n  categories Category\n}\n\nTable Category {\n  id Int [pk, increment]\n  name String [not null]\n  posts Post\n}\n\nTable CategoryToPost {\n  categoriesId Int [ref: \u003e Category.id]\n  postsId Int [ref: \u003e Post.id]\n}\n\nEnum Role {\n  ADMIN\n  USER\n}\n\nRef: Profile.userId - User.id\n\nRef: Post.authorId \u003e User.id\n```\n\n4. [Visualize](https://dbdiagram.io/d) the `schema.dbml`\n\n## Additional Options\n\n| Option                  |  Description                                    | Type      |  Default      |\n| ----------------------- | ----------------------------------------------- | --------- | ------------- |\n| `projectDatabaseType`   | Project database type for dbdocs                | `string`  | `null`        |\n| `projectName`           | Project name for dbdocs                         | `string`  | `null`        |\n| `projectNote`           | Project note for dbdocs                         | `string`  | `null`        |\n| `projectNotePath`       | Project note path to a markdown file for dbdocs | `string`  | `null`        |\n| `output`                | Output directory for the DBML file              | `string`  | `./dbml`      |\n| `outputName`            | Name for the DBML file                          | `string`  | `schema.dbml` |\n| `manyToMany`            | Create Many-To-Many join table                  | `boolean` | `true`        |\n| `mapToDbSchema`         | Use mapped table name                           | `boolean` | `true`        |\n| `includeRelationFields` | Include relation fields                         | `boolean` | `true`        |\n\nUse additional options in the `schema.prisma`\n\n```prisma\ngenerator dbml {\n  provider   = \"prisma-dbml-generator\"\n  output     = \"../dbml\"\n  outputName = \"awesome.dbml\"\n  projectName = \"Project Name\"\n  projectDatabaseType = \"PostgreSQL\"\n  projectNote = \"Test project description\"\n}\n```\n\n## Development\n\n```bash\nnpm run dev\n\nnpm test\n```\n\n## Helpful\n\n[Prisma Generator](https://github.com/prisma/specs/tree/master/generators)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotiz-dev%2Fprisma-dbml-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotiz-dev%2Fprisma-dbml-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotiz-dev%2Fprisma-dbml-generator/lists"}