Skip to content
migration.tools
SQL DDL to Prisma

SQL to Prisma schema converter

Adopting Prisma on an existing database without a live connection to introspect? Paste the schema and get models with @id, @default, @unique, @relation and @@index attributes, plus @@map so model names follow Prisma conventions while tables keep their real names.

Options

CREATE TABLE statements

schema.prisma

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your SQL DDL or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the Prisma or download it. Drop several files to convert a batch into one ZIP.

What gets generated

Each table becomes a model named in singular PascalCase, mapped back to the original table with @@map. Columns keep their names; types map to Prisma scalars with native @db attributes where precision matters, such as @db.VarChar(191) or @db.Decimal(10, 2).

Foreign keys become relation fields on both sides — the scalar and @relation field on the child, the list field on the parent — with onDelete carried over. When two foreign keys point at the same table, relations are named so Prisma can tell them apart.

AUTO_INCREMENT, SERIAL and IDENTITY become @default(autoincrement()), CURRENT_TIMESTAMP becomes @default(now()), and ON UPDATE CURRENT_TIMESTAMP becomes @updatedAt.

Questions

How is this different from prisma db pull?

prisma db pull needs a running database and credentials. This works from a .sql file alone, which helps when you only have a dump, when the database is in a network you can't reach, or when you're reviewing a schema before it exists.

Should I run prisma format afterwards?

Yes. The output is valid Prisma schema language; prisma format will align the columns and validate the relations against your Prisma version.

Guides that use this tool