Exercise 3: One Command for a Fresh Database — Possible Solution ================================================================= package.json: "scripts": { "db:migrate": "prisma migrate dev", "db:seed": "prisma db seed", "db:fresh": "prisma migrate reset --force && prisma generate && prisma db seed" } $ npm run db:fresh What each part does: prisma migrate reset --force Drops the database (or all its data), recreates it and applies every migration from scratch. --force skips the "are you sure?" prompt, so this script must never point at a production DATABASE_URL. prisma generate Regenerates the client. In Prisma 7, migrate commands don't run generate for you, so a fresh checkout would otherwise have a missing or stale client. prisma db seed Runs the command configured under migrations.seed in the Prisma config file. Why it matters more in Prisma 7: In Prisma 6, "migrate reset" (and "migrate dev" on a new database) ran the seed script automatically. Prisma 7 removed automatic seeding (and automatic generate), so a reset now leaves you with correct tables but no data at all. Without a script like db:fresh, it's easy to reset, start the app, and wonder why the blog is empty — or for two developers to end up with different data because one forgot to seed. WHY THIS WORKS AS AN ANSWER ------------------------------ It chains the three steps in the only order that works (schema, then client, then data), uses && so a failed step stops the rest, and explains the Prisma 7 change that made this explicit script necessary. The warning about --force matters: a script that wipes data without asking should only ever be run against development databases.