What problem does it solve?
Database initialization and test fixture creation are repetitive and fragile tasks that often fail on duplicate keys or require manual scripts per project. Prisma seed scripts, when misconfigured, can be non-idempotent, hang the process, or be difficult to integrate into migration workflows. This Skill centralizes best practices for creating safe, repeatable seeds that developers can run reliably in development and test environments.
Core Features & Use Cases
- Idempotent seeding with upsert: Use upsert and update: {} patterns so seeds can run multiple times without P2002 duplicate errors.
- Seed runner configuration: Configure prisma.seed in package.json to point to a TypeScript or JavaScript runner such as tsx, ts-node, or node.
- Bulk and generated data: Support bulk inserts with createMany and realistic data generation with @faker-js/faker for fixtures and load data.
- Automation helper: Includes a script to generate a starter prisma/seed.ts and add the seed command to package.json for quick setup.
- Use case: Initialize a fresh development database with admin users, lookup tables, and sample posts after applying migrations.
Quick Start
Create a prisma/seed.ts that uses upsert for your core models, add prisma.seed to package.json to run tsx prisma/seed.ts, and run npx prisma db seed to populate the database.