Prisma schema to SQL converter (PostgreSQL)

Convert a Prisma schema to SQL for PostgreSQL: exactly the CREATE TABLE statements prisma migrate would write for an empty database, including enums, indexes, foreign keys, many-to-many join tables and Prisma's constraint names.

Prisma

PostgreSQL

Waiting for input

What you get

How each result is checked

  1. Your schema is validated and read by Prisma's own schema engine (Prisma 7), so it is understood exactly as Prisma would.
  2. The SQL is parsed back with the real PostgreSQL parser and compared with what Prisma's engine says the schema means: every table and column, its PostgreSQL type (by Prisma's documented type mapping), NOT NULL, database defaults, primary keys, unique and normal indexes (names, columns, method, sort order), foreign keys (names, columns, ON DELETE/ON UPDATE), implicit many-to-many join tables and enums.

What can't convert exactly

  • @default(uuid()), cuid(), nanoid(), ulid() and @updatedAt are filled in by Prisma Client, not the database, so those columns have no database default (same as prisma migrate). They are listed in the warnings.
  • With relationMode = "prisma" no foreign keys are created, as with prisma migrate.
  • Only the PostgreSQL provider is supported.

Questions

Is this the same as prisma migrate?

Yes, that is the goal and what the tests check: for every test schema (and every SQL test schema converted to Prisma and back), the output is compared character for character with prisma migrate diff --from-empty --script, run with Prisma's own migration engine, and then executed in a real Postgres.

Do I need a database?

No. Everything runs in your browser; nothing is sent anywhere.

What about Unsupported("…") fields and @@ignore models?

They are created like prisma migrate creates them: Unsupported fields with their exact type, and ignored models and fields as normal tables and columns.

How do I convert Prisma to SQL without a database?

Paste your schema.prisma here. You get the SQL prisma migrate would run on an empty PostgreSQL database, generated and checked in your browser, so no database or install is needed.

How do I see the SQL that prisma migrate will run?

Paste your schema.prisma here: the SQL is the same as prisma migrate diff from an empty database writes for PostgreSQL, without installing Prisma or connecting to a database. Prisma to SQL online, in your browser.

How do I convert Prisma to PostgreSQL online?

Paste your Prisma or open a file on the left (or click Example). The PostgreSQL appears on the right as you type, already checked. Copy it, or download it as a file. Nothing is uploaded.

Can the PostgreSQL output be wrong?

Every result is checked before it is shown (the checks are listed on this page). If a check fails, the page says "Review needed" and why, instead of presenting the output as correct, and anything that cannot convert exactly is named in the notes.