Configure and run Prisma's integrated database seeding via prisma db seed, including wiring the seed command in prisma.config.ts and initializing Prisma Client with a driver adapter inside the seed script.

domain: prisma.io · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Install seed-script dependencies, e.g. for Postgres: `npm install --save-dev typescript tsx @types/node @prisma/adapter-pg pg @types/pg dotenv`.
  2. Create prisma/seed.ts that initializes PrismaClient with a driver adapter and creates records, e.g.: `import { PrismaPg } from "@prisma/adapter-pg"; import { PrismaClient } from "../prisma/generated/client"; const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL }); const prisma = new PrismaClient({ adapter }); async function main() { await prisma.user.upsert({ where: { email: "alice@prisma.io" }, update: {}, create: { email: "alice@prisma.io", name: "Alice" } }); } main().then(() => prisma.$disconnect()).catch(async (e) => { console.error(e); await prisma.$disconnect(); process.exit(1); });`
  3. Register the seed command in prisma.config.ts under migrations.seed: `export default defineConfig({ schema: "prisma/schema.prisma", migrations: { path: "prisma/migrations", seed: "tsx prisma/seed.ts" }, datasource: { url: env("DATABASE_URL") } });`. This replaces the old package.json "prisma": { "seed": ... } convention.
  4. Run seeding on demand with `npx prisma db seed`. To pass custom arguments to your seed script, use the `--` delimiter, e.g. `npx prisma db seed -- --environment development`, and parse them in the script with Node's parseArgs.
  5. For non-JS seeding, point migrations.seed at any executable, e.g. a shell script running psql or a Go binary (`seed: "sh prisma/seed.sh"`).
  6. Reference: https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding

Known gotchas

Related routes

Set up a brand-new Prisma ORM v7 project: initialize the CLI, configure prisma.config.ts and schema.prisma with a datasource, install a driver adapter, and generate a working Prisma Client.
prisma.io · 8 steps · unrated
Introspect an existing database and generate/refresh a Prisma schema from it using prisma db pull, then produce a working Prisma Client from the introspected schema.
prisma.io · 7 steps · unrated

Give your agent this knowledge — and 17,200+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans