Schema-aware Prisma seed generator.
SeedForge reads schema.prisma, analyzes models and relations, and generates a working prisma/seed.ts. It is built for development workflows where schemas change often and seed scripts become expensive to maintain by hand.
Manual Prisma seeds usually drift in the same places:
- required fields change
- relation order breaks
- new models are missed
- local environments stop matching each other
SeedForge generates deterministic relational seed code from the schema instead of relying on a hand-maintained seed file.
- Parses Prisma schema metadata with DMMF
- Builds a dependency graph from model relations
- Orders inserts to satisfy foreign keys
- Generates deterministic values for required scalars, enums, and scalar lists
- Supports model-level
count,perParent, anddisabledconfig - Generates Prisma 7-compatible Postgres seeds using
@prisma/adapter-pg - Makes generated seeds idempotent by clearing existing data in reverse dependency order
Example dependency chain:
Category -> Product -> ProductVariant
Customer -> Order -> OrderItem -> Payment
npm install -D seedforge- Generate a seed:
npx seedforge generate- Generate the Prisma client:
npx prisma generate- Run the seed:
npx prisma db seedRecommended workflow after schema changes:
npx prisma migrate dev
npx seedforge generate --force
npx prisma generate
npx prisma db seedSeedForge supports Prisma 7-style config-driven datasource URLs.
Example prisma.config.ts:
import "dotenv/config";
import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
seed: "tsx prisma/seed.ts",
},
datasource: {
url: env("DATABASE_URL"),
},
});Example datasource block in prisma/schema.prisma:
datasource db {
provider = "postgresql"
}For Prisma 7 Postgres projects, generated seeds initialize Prisma Client with @prisma/adapter-pg.
Generate prisma/seed.ts from the current schema.
Useful flags:
--schema <path>: custom schema path--output <path>: custom output file--dry-run: print generated seed without writing--force: overwrite an existing file
Create seedforge.config.ts.
Validate schema loading and dependency ordering.
Print an ASCII dependency graph.
Remove the generated seed file.
Create seedforge.config.ts in the project root:
export default {
global: {
count: 5,
},
models: {
Category: { count: 6 },
Product: { perParent: 8 },
ProductVariant: { perParent: 3 },
Payment: { disabled: true },
},
};Rules:
count: total records for a modelperParent: records created per required parent relationdisabled: skip a model entirely
Generated seeds are deterministic for the same schema and config. That makes them easier to diff, rerun, and debug.
The generated file:
- imports Prisma Client
- clears existing records in reverse dependency order
- creates parent models before children
- reuses created record IDs for required foreign keys
- emits enum values from the schema
- emits scalar lists when required
Works best for development seeding on relational Prisma schemas, especially:
- ecommerce apps
- SaaS products
- dashboards and admin tools
- content systems
Databases:
- PostgreSQL
- MySQL
- SQLite
- CockroachDB
- MongoDB support is best-effort at schema parsing level
SeedForge generates valid scaffolding, not domain-perfect fixture data.
You may still want to customize:
- business-specific enums and statuses
- auth-sensitive fields
- highly constrained unique data
- special relation strategies for edge-case schemas
npm install
npm run build
npm run dev -- generate --dry-runSee examples/README.md for sample schemas and configs.
MIT