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.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
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.