SQL DDL to Prisma Schema Converter (Models, Relations & Enums)
Translate SQL CREATE TABLE DDL statements into clean Prisma ORM schema models, relations, field attributes, and enums.
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
enum OrderStatus {
PENDING
PROCESSING
PAID
SHIPPED
DELIVERED
CANCELLED
}
enum UserRole {
ADMIN
CUSTOMER
MERCHANT
}
model User {
id String @id @default(uuid()) @db.Uuid
email String @unique @db.VarChar(255)
fullName String? @map("full_name") @db.VarChar(150)
role UserRole @default("CUSTOMER")
isVerified Boolean @default(false) @map("is_verified")
metadata Json?
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz
userProfile UserProfile?
orders Order[]
@@map("users")
}
model UserProfile {
id String @id @default(uuid()) @db.Uuid
userId String @unique @map("user_id") @db.Uuid
avatarUrl String? @map("avatar_url") @db.VarChar(500)
phoneNumber String? @map("phone_number") @db.VarChar(32)
shippingAddress String? @map("shipping_address") @db.Text
taxIdentifier String? @map("tax_identifier") @db.VarChar(64)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("user_profiles")
}
model Product {
id Int @id @default(autoincrement())
sku String @unique @db.VarChar(64)
title String @db.VarChar(200)
description String? @db.Text
unitPrice Decimal @default(0.00) @map("unit_price") @db.Decimal(12, 2)
inventoryCount Int @default(0) @map("inventory_count")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
orderItems OrderItem[]
@@index([sku])
@@map("products")
}
model Order {
id String @id @default(uuid()) @db.Uuid
customerId String @map("customer_id") @db.Uuid
orderNumber String @unique @map("order_number") @db.VarChar(64)
status OrderStatus @default("PENDING")
totalAmount Decimal @default(0.00) @map("total_amount") @db.Decimal(12, 2)
taxAmount Decimal @default(0.00) @map("tax_amount") @db.Decimal(10, 2)
shippingNotes String? @map("shipping_notes") @db.Text
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz
customer User @relation(fields: [customerId], references: [id], onDelete: Restrict)
orderItems OrderItem[]
@@index([status])
@@map("orders")
}
model OrderItem {
id Int @id @default(autoincrement())
orderId String @map("order_id") @db.Uuid
productId Int @map("product_id")
quantity Int @default(1)
unitPrice Decimal @map("unit_price") @db.Decimal(12, 2)
subtotal Decimal @db.Decimal(12, 2)
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
product Product @relation(fields: [productId], references: [id], onDelete: Restrict)
@@unique([orderId, productId])
@@map("order_items")
}100% Client-Side Privacy
Zero server uploads or database connections. All SQL parsing, AST extraction, and Prisma schema generation occur strictly in your local browser sandbox.
Intelligent Relation & Key Resolution
Automatically resolves inline and composite foreign keys into typed Prisma @relation directives, bidirectional back-references, and compound @@id / @@unique constraints.
Multi-Dialect DDL Engine
Seamlessly handles PostgreSQL, MySQL, SQLite, and SQL Server syntax including SERIAL, UUID defaults, native types, composite indexes, and custom enums.