← DocsMeridian
Recipe

Recipe: Prisma schema writer

Generate type-safe Prisma schemas from natural language descriptions.

Overview

This recipe accepts a plain-English description of your data model and emits a complete schema.prisma file with models, relations, enums, and indexes.

Input

{
  "description": "A blog with users, posts, and comments.
  Users have many posts. Posts have many comments.
  Track createdAt and updatedAt on all models."
}

Output

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model User {
  id        String    @id @default(cuid())
  email     String    @unique
  name      String?
  posts     Post[]
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
}

model Post {
  id        String    @id @default(cuid())
  title     String
  content   String?
  author    User      @relation(fields: [authorId], references: [id])
  authorId  String
  comments  Comment[]
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
}

model Comment {
  id        String   @id @default(cuid())
  body      String
  post      Post     @relation(fields: [postId], references: [id])
  postId    String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Usage

Paste the output into your project's prisma/schema.prisma, then run npx prisma migrate dev.