After an upgrade from Prisma 6 to 7, why does `prisma migrate reset` leave tables empty and `migrate dev --skip-seed` fail, and how do you fix it?
answer
- nothing runs on its own any more
- removed flags, removed env variables
- migrations.seed in the config file
- generate, then db seed, explicitly
basics
~20 sPrisma 7 stopped running the seed from migrate dev and migrate reset, stopped running generate from migrate dev and db push, and removed --skip-seed and --skip-generate. Run prisma generate and prisma db seed yourself, with the seed under migrations.seed.
solid answer
~40 sIn Prisma 6, `migrate dev` and `migrate reset` ran the seed script after applying migrations, and `migrate dev` and `db push` also ran `prisma generate`. Prisma 7 removed both: those commands now only change the database. The opt-out flags went with them, so `--skip-seed` and `--skip-generate` now fail with `unknown or unexpected option`, and the `PRISMA_MIGRATE_SKIP_SEED` and `PRISMA_MIGRATE_SKIP_GENERATE` variables are gone. Seeding happens only when you run `prisma db seed`, which runs the command in `migrations.seed` of `prisma.config.ts`; without it, it prints `No seed command configured`. The fix is to make each step explicit, for example `prisma migrate reset --force && prisma generate && prisma db seed`, delete the old flags, and run generate before the seed, because the seed script imports the generated client.
code
bash · 7 lines# Prisma 6 style: now fails with "unknown or unexpected option: --skip-seed"
npx prisma migrate dev --skip-seed
# Prisma 7: every step explicit
npx prisma migrate reset --force
npx prisma generate
npx prisma db seedgo deeper
Remember that in Prisma 7 you run prisma generate and prisma db seed yourself; migrate dev and migrate reset no longer do it.
Name exactly which commands lost which implicit steps, which flags and variables were removed, and where the seed command is now declared.
Diagnose an upgraded project from its symptoms (empty tables, unknown option errors, a stale client) and rewrite its scripts in the right order.
Use the upgrade to make database setup explicit in every script and pipeline, and decide which seed data is reference data and which belongs only to tests.
## What Prisma 6 did for you Before Prisma 7, several Migrate commands quietly ran extra steps: - `prisma migrate dev` applied migrations and then ran both `prisma generate` and the seed script. - `prisma migrate reset` dropped and rebuilt the database, then ran the seed script. - `prisma db push` synced the schema, then ran `prisma generate`. Teams opted out with `--skip-generate` and `--skip-seed`, or with the `PRISMA_MIGRATE_SKIP_GENERATE` and `PRISMA_MIGRATE_SKIP_SEED` environment variables. Onboarding scripts and test setups came to depend on the implicit steps without naming them. ## What Prisma 7 changed | | Prisma 7 behaviour | |---|---| | `prisma migrate dev` | creates and applies migrations only; no generate, no seed | | `prisma migrate reset` | drops, recreates and applies migrations only; no seed | | `prisma db push` | syncs the schema only; no generate | | `--skip-generate` (`migrate dev`, `db push`), `--skip-seed` (`migrate dev`) | removed; passing one fails with `unknown or unexpected option` | | `PRISMA_MIGRATE_SKIP_GENERATE`, `PRISMA_MIGRATE_SKIP_SEED` | removed | | Where the seed command lives | `migrations.seed` in `prisma.config.ts`, run only by `prisma db seed` | One trap: in 7.10 the help text of `prisma migrate dev` still describes it as triggering generators. The command does not; trust the behaviour, not the banner. ## The symptoms after an upgrade - `prisma migrate reset --force` finishes with `Database reset successful` and empty tables, so tests that expect reference rows fail. - Any script that still passes `--skip-seed` or `--skip-generate` stops immediately with `unknown or unexpected option`. - Type errors, or runtime errors about missing fields, appear because the generated client still reflects the previous schema. - `prisma db seed` prints `No seed command configured` and tells you to add a `seed` property to the `migrations` section of the Prisma config file. A `prisma.seed` key left in `package.json` is not read. ## The fix 1. **Declare the seed command** in `prisma.config.ts`: ```ts import { defineConfig, env } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", migrations: { path: "prisma/migrations", seed: "node prisma/seed.js", }, datasource: { url: env("DATABASE_URL") }, }); ``` 2. **Spell every step out** in scripts: `prisma migrate reset --force && prisma generate && prisma db seed`. In development, follow `prisma migrate dev` with `prisma generate`. 3. **Delete the old opt-outs**: the two flags and the two environment variables no longer exist. 4. **Order generate before seed.** The seed script imports `PrismaClient` from the generator's output path (and in Prisma 7 constructs it with a driver adapter), so it needs a client that matches the new schema. 5. **Make the seed safe to rerun**, for example with `upsert`, because it is now a command people run on its own, as often as they like. Arguments reach the seed script after a `--` delimiter, for example `prisma db seed -- --environment test`. ## A test-database setup, step by step A disposable database for an integration-test run now reads as three explicit commands, in this order: 1. `prisma migrate reset --force` drops the test database, recreates it and applies every migration, and in Prisma 7 stops there. 2. `prisma generate` writes a client that matches the current schema, unless the build has already done so. 3. `prisma db seed -- --environment test` loads the reference rows the tests expect. Leaving out step 3 is what produces the empty tables from the question; leaving out step 2 produces the stale types. ## What did not change - `prisma migrate deploy` applies pending migrations and nothing else; it neither generates the client nor seeds. - `prisma migrate reset` still asks for confirmation. In a non-interactive shell without `--force` it fails, saying the environment is non-interactive and suggesting `--force`, so scripts keep the flag. - `prisma db seed` itself stays: it is now the only way the seed command runs. - The seed command can be any shell command, such as `node prisma/seed.js`; Prisma runs it as given. ## Why the change is an improvement Implicit steps hid cost and surprise. A reset in a test pipeline could start a long seed nobody asked for, and a client regenerated as a side effect of a migration masked a build that never ran `prisma generate` itself. In Prisma 7 each command does one thing, and the script says exactly what runs. The price is the one-time upgrade work above.
- Why must `prisma generate` run before `prisma db seed` in a fresh checkout?The seed script imports `PrismaClient` from the generator's output path. In Prisma 7 nothing generates that client as a side effect of `migrate reset` or `migrate dev`, so on a fresh checkout or after a schema change the import is missing or stale until `prisma generate` runs.
- How do you seed different data for tests and for local development with `prisma db seed`?Pass arguments after the `--` delimiter, such as `prisma db seed -- --environment test`, and read them in the seed script, for example with Node's `parseArgs`. The configured `migrations.seed` command receives them as extra arguments.
- migrate reset still seeds; the seed script itself must be broken
- Replace --skip-seed with --skip-generate to silence the error
- prisma db seed falls back to the seed key in package.json
- migrate dev regenerates the client, so a separate generate is redundant
- Prisma 7 removed prisma db seed along with automatic seeding
Prisma 7 removed automatic seeding from migrate dev and migrate reset, automatic generate from migrate dev and db push, and the --skip-seed and --skip-generate flags.