Paste a CREATE TABLE statement and get the equivalent Prisma or Drizzle schema.
}
function escapeHtml(s) { return s.replace(/&/g,β&β).replace(/</g,β<β).replace(/>/g,β>β); }
Supported types
PostgreSQL types mapped to both Prisma and Drizzle: serial, integer, bigint, text, varchar(n), boolean, timestamp, date, float, numeric, json, jsonb, uuid.
Limitations
- Handles standard
CREATE TABLEsyntax (PostgreSQL-flavored) - Foreign keys and relations need manual adjustment
- Complex defaults or expressions may need tweaking
- MySQL-specific types may not map perfectly
FAQ
Should I use an ORM or write raw SQL?
Use an ORM for CRUD operations, type safety, and migrations. Use raw SQL for complex queries, performance-critical paths, and reporting. Most production apps use both β ORM for 90% of queries, raw SQL for the complex 10%. See Prisma vs Drizzle vs TypeORM for a comparison.
Does this converter handle relationships (foreign keys)?
It converts basic foreign key constraints to ORM relation decorators. However, complex relationships (many-to-many with extra columns, polymorphic relations, self-referencing) may need manual adjustment after conversion.
Can I convert from ORM back to SQL?
Most ORMs have a migration system that generates SQL from your schema. Prisma uses prisma migrate, TypeORM uses typeorm migration:generate, and Drizzle uses drizzle-kit generate. These produce the SQL equivalent of your ORM schema.
Which ORM should I choose for a new project?
For TypeScript: Drizzle if you want SQL-like syntax with full type safety, Prisma if you want the best DX and donβt mind a build step, TypeORM if youβre coming from Java/C# and prefer decorators. For Python: SQLAlchemy is the standard. For Go: GORM or sqlc (generates Go from SQL).
Related resources
- SQL Cheat Sheet
- Prisma Cheat Sheet
- SQL Formatter & Beautifier
- How Database Indexes Actually Work
- MongoDB vs PostgreSQL