Skip to content

feat: Add Prisma schema export support#861

Open
Divyapahuja31 wants to merge 3 commits intodrawdb-io:mainfrom
Divyapahuja31:feat/export-to-prisma
Open

feat: Add Prisma schema export support#861
Divyapahuja31 wants to merge 3 commits intodrawdb-io:mainfrom
Divyapahuja31:feat/export-to-prisma

Conversation

@Divyapahuja31
Copy link
Copy Markdown
Contributor

Description

This PR introduces the ability to export diagrams directly to Prisma Schema (.prisma) format.

Currently, DrawDB supports exporting to SQL (MySQL, PostgreSQL, etc.), DBML, and Mermaid. With Prisma being a standard ORM for modern web development (especially in the Next.js/TypeScript ecosystem), adding direct export support allows users to go from Visual Design -> schema.prisma instantly.

Changes

  • New Utility: Added src/utils/exportAs/prisma.js. This module handles the conversion logic, mapping internal DrawDB types to Prisma scalars (e.g., VARCHAR -> String, INT -> Int) and constructing proper model, enum, and datasource blocks.
  • Relationship Handling: Implements logic to correctly generate Prisma-compatible relationship fields (@relation, fields, references) for 1:1, 1:n, and n:1 relationships.
  • UI Update: Added "Prisma" to the Export As dropdown menu in ControlPanel.jsx.

Features Implemented

  • ✅ Mapping of all standard SQL data types to Prisma Scalar types.
  • ✅ Support for @id, @unique, @default, and autoincrement().
  • ✅ Valid generation of Enums.
  • ✅ Correct relation attribute syntax for standard relationships.
  • ✅ Basic datasource and generator block scaffolding.

How to Test

  1. Open the editor.
  2. Create a few tables with relationships (e.g., simpler User -> Posts setup).
  3. Click File > Export As > Prisma.
  4. Verify the downloaded file is a valid schema.prisma file.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added a new export module that mirrors existing patterns (like dbml.js)
  • My changes generate valid syntax

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 6, 2026

Someone is attempting to deploy a commit to the dottle's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant