← All tools
Free tool
SQL to Prisma schema converter
Turn PostgreSQL CREATE TABLE statements into a ready-to-use schema.prisma, models, native type mappings, ids, defaults, and relations on both sides.
schema.sql · 33 lines
schema.prisma · 5 models
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Users {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String
name String
createdAt DateTime? @default(now()) @db.Timestamptz
posts Posts[]
comments Comments[]
}
model Posts {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
userId String @db.Uuid
title String
body String?
createdAt DateTime? @default(now()) @db.Timestamptz
users Users @relation(fields: [userId], references: [id])
comments Comments[]
postTags PostTags[]
}
model Tags {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
postTags PostTags[]
}
model Comments {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
postId String @db.Uuid
userId String @db.Uuid
content String
posts Posts @relation(fields: [postId], references: [id])
users Users @relation(fields: [userId], references: [id])
}
model PostTags {
postId String @id @db.Uuid
tagId String @id @db.Uuid
posts Posts @relation(fields: [postId], references: [id])
tags Tags @relation(fields: [tagId], references: [id])
@@map("post_tags")
}
Frequently asked questions
Related tools
Keep exploring
Turn it into an ER diagram
Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.