ORM Model Generation
Generate ORM models in DDLBuilder. Start with the getting started guide or import existing SQL if you do not have a table yet. For cross-table references, check the foreign keys and ER diagram first.
SQLite / D1 supports Drizzle output. Use the group export for cross-table foreign keys. See Query Design and Modeling for type mapping and initialization limits.
This guide details how to export schema designs directly into strongly typed model classes across industry-standard ORM frameworks.
Example: convert a MySQL users table to a Prisma model
This example generates a single-table model without cross-table relationships. Open DDLBuilder, select MySQL, and import this SQL:
CREATE TABLE users (
id INT NOT NULL,
name VARCHAR(100) NOT NULL,
PRIMARY KEY (id ASC)
);Select users, open the ORM tab on the right, and choose Prisma. The generated model is shown below; alignment spacing may differ.
model Users {
id Int @id
name String
@@map("users")
}The primary key on id maps to @id, name becomes a required String, and @@map("users") preserves the database table name. There is no auto-increment or default value in this example, so inserts must provide both id and name.
This is a model fragment. Configure the MySQL datasource and client generator in your own Prisma project, validate the model, then generate the client or migrations according to your project's workflow. Model generation does not connect to or modify your database. For a users-and-orders relationship, continue with foreign keys and ER diagrams.
Overview
Bridge database modeling and backend engineering by generating clean, typed, and annotated model code without manual transcription errors.
Operations Walkthrough
1. Select Target Framework
- Switch to the ORM tab in the right-hand output panel.
- Select your framework from the dropdown:
- Prisma (Node.js / TypeScript)
- TypeORM (TypeScript / NestJS)
- SQLAlchemy (Python / FastAPI / Django)
- GORM (Go / Gin / Fiber)
- JPA / Hibernate (Java / Spring Boot)
- The editor immediately renders framework-compliant entity definitions.
2. Copy Code to Your Project
Click Copy ORM to copy the generated class or schema to your clipboard, then paste it directly into your application codebase.
Frameworks and Type Mapping Specifications
| Framework | Output Format | Common Annotations and Constructs |
|---|---|---|
| Prisma | .prisma schema file | @id, @default(), @map(), @unique, @@index, @@schema |
| TypeORM | TypeScript Entity class | @Entity(), @PrimaryGeneratedColumn(), @Column({ type, precision }), @Index() |
| SQLAlchemy | Python Declarative class | Column(), Integer(), String(), DECIMAL(), __table_args__ |
| GORM | Go Struct | gorm.Model, gorm:"column:xxx;type:xxx;primaryKey;uniqueIndex" |
| JPA | Java Entity class | @Entity, @Table(name, schema), @Id, @Column(name, nullable), @Index |
Precision Safety & Schema Namespace Details
Type Safety and Namespaces
- High-Precision Decimals & BigInt: In TypeORM outputs,
bigintanddecimal/numerictypes are mapped tostringproperties to prevent JavaScript float precision truncation. - Schema Namespaces:
- Prisma: Appends
@@schema("schemaName")for PostgreSQL and SQL Server. - SQLAlchemy: Declares
schema='schemaName'in__table_args__. - JPA: Binds
schema = "schemaName"within@Table. - GORM: Implements a custom
TableName()method returning the qualified table name.
- Prisma: Appends
Verification Checklist
- [ ] Generated ORM fields, primary keys, and column attributes match table configurations.
- [ ] Pasted model files compile and pass static type checks cleanly.
- [ ] Schema namespaces are appropriately declared in framework-specific configurations.