$ recombobulate _
home / tips / convert-your-sql-schema-to-a-prisma-schema-with-claude
0

Convert Your SQL Schema to a Prisma Schema with Claude

bagwaa @bagwaa · Mar 26, 2026 · Workflows
convert-your-sql-schema-to-a-prisma-schema-with-claude

Migrating an existing database to Prisma means translating your DDL into Prisma's schema language by hand — or you can just ask Claude to do it.

Dump your schema and pipe it straight in:

pg_dump --schema-only mydb | claude -p "Convert this PostgreSQL DDL into a valid Prisma schema. Infer all relations from foreign key constraints, map PostgreSQL types correctly, and add @@map and @map attributes to preserve the original table and column names."

Claude handles the tricky parts: composite primary keys, enums, JSON columns, self-referential relations, and many-to-many join tables that Prisma needs to model as implicit or explicit relations.

For a Laravel project migrating to a Node.js backend, the combination is especially useful:

cat database/migrations/*.php | claude -p "Extract the final schema state from these Laravel migration files and produce a Prisma schema file with correct relations and types."

Once the schema is generated, ask Claude to keep going:

claude "Now generate Prisma seed data in seed.ts that matches the existing fixtures in tests/fixtures/. Use the Prisma client we just created."

You can also ask Claude to spot any differences between your introspected schema and the Prisma output — a good sanity check before running migrations.

Claude turns a multi-hour schema migration into a single session — just verify the relations before you run prisma migrate.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago