< We're launched Liam ERD!

Learn More

20250116 - Use DMMF for Prisma Schema Parsing

Status

  • Proposed
  • Accepted
  • Rejected
  • Deprecated
  • Superseded

Context

We need to parse Prisma schema files to extract database structure information. Several approaches were considered:

  1. JavaScript parsers (e.g., Acorn, Babel)
  2. Custom parsers using parser generators (e.g., PEG.js)
  3. DMMF (Data Model Meta Format) from @prisma/internals

Each approach has different implications for maintenance, accuracy, and development effort. JavaScript parsers were immediately ruled out as they are designed for parsing JavaScript code, not Prisma's custom schema format.

Decision

We will use DMMF from @prisma/internals to parse Prisma schema files. DMMF is Prisma's internal representation format used for schema parsing and validation. Using DMMF is more reliable and accurate for parsing Prisma schema files compared to custom parsers.

Key factors in this decision:

  • Official support from Prisma team
  • Comprehensive parsing of models, fields, and relationships
  • Built-in validation and type safety
  • Automatic compatibility with future Prisma updates
  • De facto stability demonstrated by widespread usage in the Prisma ecosystem

Consequences

Positive

Negative

Neutral

  • Need to transform DMMF output to match our internal database structure format
  • Learning curve for working with DMMF API

On this page