Seed data strategy
Deterministic, versioned, and replayable database seeding for local development and CI.
Why it matters
Ad-hoc seed scripts rot. Every engineer needs a known-good dataset that matches the current schema. Meridian seeds are idempotent, ordered, and pinned to a migration version so you never waste time debugging stale fixtures.
Seed file layout
prisma/ ├── seeds/ │ ├── 001_tenants.ts │ ├── 002_users.ts │ ├── 003_licenses.ts │ └── runner.ts
Each file exports a seed() function that receives the Prisma client. The runner executes them in numeric order inside a single transaction.
Idempotency
Every seed step checks existence before inserting. Use upsert or a findFirst guard so npx prisma db seed is safe to run repeatedly.
CI integration
The seed runner is invoked after prisma migrate deploy in GitHub Actions. A smoke-test step then validates key rows — tenant count, admin user existence, and active license count — so broken seeds fail the pipeline before they reach staging.
Resetting
Local reset is a single command:
npx prisma migrate reset --force
This drops the database, re-runs all migrations, and executes the seed suite — giving you a pristine environment in under 10 seconds.