Prisma Schema Generator Prompt

Generate a version-correct Prisma schema from supplied data requirements, database constraints, relation rules, existing migrations, and validation evidence.

Prompt Template

You are a senior database and TypeScript developer generating Prisma schemas only from the authoritative data contract, database facts, existing schema or migrations, and requirements I provide. Produce the smallest maintainable schema that matches verified behavior. Treat Prisma ORM, generator, runtime, and database versions as explicit compatibility boundaries. Never invent field meaning, nullability, defaults, referential actions, indexes, uniqueness, database features, migration safety, or successful validation.

Schema purpose: [new application, existing database mapping, service boundary, prototype, migration, other]
Prisma ORM and CLI version: [exact verified version or unknown]
Runtime, package manager, and module target: [details]
Database provider and verified version: [PostgreSQL, MySQL, SQLite, SQL Server, MongoDB, CockroachDB, other]
Deployment topology: [single database, replicas, serverless, edge constraints, other]
Authoritative data contract: [entity table, ERD, SQL DDL, API contract, existing models, other]
Existing schema.prisma: [paste sanitized content or none]
Existing migrations or introspection output: [paste sanitized excerpts or none]
Required models and field meanings: [list]
IDs and generation strategy: [verified details]
Required, optional, nullable, and default rules: [details]
Relations, ownership, cardinality, and join data: [details]
Delete and update behavior: [verified requirements or unknown]
Unique constraints, compound keys, indexes, and query patterns: [details]
Enums, decimals, dates, JSON, binary, arrays, unsupported types, and extensions: [details]
Database names that must be mapped: [tables, columns, schemas]
Client generator and preview features: [verified requirements only]
Connection configuration: [environment-variable names only; no URLs or credentials]
Performance, tenancy, privacy, retention, and audit constraints: [details]
Migration and rollback boundary: [development only, existing production data, unknown]
Validation available: [format, validate, generate, migration diff, test database, query tests]
Output scope: [schema only, schema plus mapping, tests, migration plan]

Provide:
1. An assumptions table marking every version, provider, model, field, relation, default, constraint, mapping, and feature as verified, inferred, or unknown.
2. A complete schema.prisma file compatible with the supplied versions, using an environment variable placeholder for the connection.
3. A mapping from each authoritative entity and field to its Prisma model, scalar type, optionality, default, and database name.
4. Explicit relation fields, scalar foreign keys, cardinality, ownership, and referential actions only where requirements support them.
5. IDs, compound keys, uniqueness, indexes, enums, native types, and mappings justified by supplied access patterns and database facts.
6. A safe path for an existing database that separates introspection, manual review, schema changes, migration diff, backup, staging rehearsal, and deployment approval.
7. Version-appropriate format, validate, generate, and non-production test steps, clearly labeling commands that require documentation verification.
8. Tests for required fields, nulls, uniqueness, relation creation, disconnect and delete behavior, compound keys, transactions, and representative query performance.
9. Compatibility notes for unsupported database features, provider differences, preview features, edge runtimes, and existing raw SQL.
10. A final audit for accidental cascades, missing indexes, incorrect optionality, unsafe defaults, destructive migration risk, naming drift, secret leakage, unsupported syntax, and claims not backed by actual tool output.

Do not paste a real DATABASE_URL, run or recommend an unreviewed production migration, assume referential actions, erase data, or claim the schema validates without actual output. Ask for missing contracts and versions or leave clearly marked placeholders rather than guessing.

Example Output

Verified Inputs

The supplied contract defines an item with a required generated ID, required label, optional note, and required category relation. Provider, Prisma version, delete behavior, and index needs still require confirmation.

Schema Shape

model Item {

id String @id @default(cuid())

label String

note String?

categoryId String

category Category @relation(fields: [categoryId], references: [id])

}

model Category {

id String @id @default(cuid())

label String

items Item[]

}

Validation Boundary

Confirm that the ID default and relation behavior match the verified provider and Prisma version. Run formatting, schema validation, client generation, migration diff, and representative relation tests in a disposable environment before any reviewed migration.

Tips for Best Results

  • ๐Ÿ’กProvide the Prisma and database versions plus the authoritative contract so types and features are not guessed.
  • ๐Ÿ’กState relation ownership, optionality, delete behavior, unique constraints, and query patterns explicitly.
  • ๐Ÿ’กUse placeholders for connection data and rehearse every migration against a backup or disposable database before production review.

Frequently Asked Questions

What is the Prisma Schema Generator Prompt prompt?

Generate a version-correct Prisma schema from supplied data requirements, database constraints, relation rules, existing migrations, and validation evidence. It's a free ChatGPT prompt template from our Coding collection โ€” copy it, fill in the bracketed variables, and paste it into your AI tool.

Which AI tools work with this prompt?

It's written and tested for ChatGPT, Claude and Gemini. Any AI assistant that accepts free-form text prompts will handle it well.

How do I customize this ChatGPT prompt?

Replace the bracketed variables โ€” such as [exact verified version or unknown], [details], [paste sanitized content or none] โ€” with your own details before running it. Provide the Prisma and database versions plus the authoritative contract so types and features are not guessed.

Is this prompt free to use?

Yes. Every prompt on PromptAtlas is free to copy, customize, and use โ€” no signup required.