A worked example, rendered from real sample data. Sign in to run the tool on your own input.
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
name VARCHAR(100),
role VARCHAR(20) DEFAULT 'user',
active BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
body TEXT,
user_id INTEGER REFERENCES users(id),
published BOOLEAN DEFAULT false
);generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
role String? @default("user")
active Boolean? @default(true)
createdAt DateTime? @default(now()) @map("created_at")
posts Post[]
@@map("users")
}
model Post {
id Int @id @default(autoincrement())
title String
body String?
userId Int? @map("user_id")
published Boolean? @default(false)
user User? @relation(fields: [userId], references: [id])
@@map("posts")
}

Convert SQL CREATE TABLE statements to Prisma schema. Part of the DevTools Surf developer suite. Browse more tools in the Data / SQL collection.