Skip to main content
AIPromptIndex
Cursor Coding intermediate

Prisma Schema Generator

Added Apr 2, 2026

Generate a complete Prisma database schema based on the following application requirements. Application description: [APP_DESCRIPTION] Core data entities: [DATA_ENTITIES] Key relationships and business rules: [RELATIONSHIPS] Database provider: [DATABASE_PROVIDER] Create a comprehensive Prisma schema that includes: 1. All models with appropriate field types, using Prisma's native types for optimal database mapping 2. Proper use of @id, @unique, @default, and @updatedAt attributes on relevant fields 3. All relationships defined with explicit relation names, including one-to-one, one-to-many, and many-to-many through join tables where appropriate 4. Indexes defined with @@index for fields commonly used in WHERE clauses, and composite indexes for frequently queried field combinations 5. Enum types for any fields with a fixed set of values like status fields, roles, or categories 6. Soft delete support using a deletedAt DateTime field on entities that should not be permanently removed 7. Audit fields on all models including createdAt, updatedAt, and optionally createdBy for tracking changes 8. A companion migration strategy noting any fields that should be added incrementally versus in the initial migration 9. Example seed data for each model showing realistic test records 10. Query examples for the 5 most common data access patterns this schema would need, using Prisma Client syntax with includes and where clauses Ensure the schema follows Prisma naming conventions with PascalCase models, camelCase fields, and explicit @map directives if the database requires different casing.
0
Share
Try in Cursor

About This Prompt

This prompt generates complete Prisma database schemas from application requirements, including models, relationships, indexes, enums, and seed data. It handles the translation from business logic to database structure, applying best practices like soft deletes, audit trails, and composite indexes that developers often forget during initial schema design. The output includes not just the schema file but also migration strategy notes and Prisma Client query examples for common access patterns. It is ideal for full-stack developers starting new projects with Prisma, teams migrating from raw SQL to an ORM, or developers who want a senior-level schema review of their data model before implementation.

Variables to Customize

[APP_DESCRIPTION]

What the application does at a high level

Example: A SaaS project management tool where organizations have workspaces, teams can create projects with tasks, and tasks support comments, file attachments, and time tracking

[DATA_ENTITIES]

The main data objects in the system

Example: Organization, Workspace, User, Team, Project, Task, Comment, Attachment, TimeEntry

[RELATIONSHIPS]

Key relationships and business rules between entities

Example: Users belong to one Organization but can be on multiple Teams. Tasks are assigned to one User but can have multiple watchers. Projects belong to one Workspace. Time entries are linked to both a Task and a User.

[DATABASE_PROVIDER]

The target database engine

Example: PostgreSQL

Tips for Best Results

  • Include any performance requirements like expected row counts per table so the index strategy can be optimized accordingly
  • Mention if you need multi-tenancy since this fundamentally affects how the schema is structured with organization-scoped queries
  • Specify if you are using Prisma with Next.js, Express, or another framework since this affects the recommended query patterns

Example Output

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

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

enum TaskStatus {
  BACKLOG
  TODO
  IN_PROGRESS
  IN_REVIEW
  DONE
  CANCELLED
}

model Organization {
  id        String   @id @default(cuid())
  name      String
  slug      String   @unique
  users     User[]
  workspaces Workspace[]
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  deletedAt DateTime?

  @@index([slug])
}
```
prisma database schema orm typescript

Get the Best AI Prompts Weekly

Curated prompts, tips, and guides delivered to your inbox every week. Free.