Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ In MongoDB databases, models are represented by _collections_ and contain _docum
}
```

Prisma Client currently expects a consistent model and [normalized model design](https://www.mongodb.com/docs/manual/data-modeling/concepts/embedding-vs-references/#references). This means that:
Prisma Client currently expects a consistent model and [normalized model design](https://www.mongodb.com/docs/manual/data-modeling/best-practices/#std-label-data-modeling-best-practices). This means that:

- If a model or field is not present in the Prisma schema, it is ignored
- If a field is mandatory but not present in the MongoDB dataset, you will get an error
Expand Down
13 changes: 11 additions & 2 deletions content/200-orm/300-prisma-migrate/300-workflows/10-seeding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ export default defineConfig({

Database seeding happens when you run `prisma db seed`. With `prisma db seed`, _you_ decide when to invoke the seed command. It can be useful for a test setup or to prepare a new development environment, for example.

:::info[Prisma ORM v7 changes]

### Prisma 6 Only
Prisma Migrate also integrates seamlessly with your seeds, assuming you follow the steps in the section below. Seeding is triggered automatically when Prisma Migrate resets the development database.
In Prisma ORM v7, seeding is **only triggered explicitly** by running `npx prisma db seed`. Automatic seeding during `prisma migrate dev` or `prisma migrate reset` has been removed.

:::

<details>
<summary>Prisma ORM v6 and earlier</summary>

In Prisma ORM v6 and earlier, Prisma Migrate also integrates seamlessly with your seeds. Seeding is triggered automatically when Prisma Migrate resets the development database.

Prisma Migrate resets the database and triggers seeding in the following scenarios:

Expand All @@ -49,6 +56,8 @@ Prisma Migrate resets the database and triggers seeding in the following scenari

When you want to use `prisma migrate dev` or `prisma migrate reset` without seeding, you can pass the `--skip-seed` flag.

</details>

## Example seed scripts

Here we suggest some specific seed scripts for different situations. You are free to customize these in any way, but can also use them as presented here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ The path to the directory where Prisma should store migration files, and look fo

### `migrations.seed`

This option allows you to define a script that Prisma runs to seed your database after running migrations or using the npx prisma db seed command. The string should be a command that can be executed in your terminal, such as with `node`, `ts-node`, or `tsx`.
This option allows you to define a script that Prisma runs when you execute the `npx prisma db seed` command. The string should be a command that can be executed in your terminal, such as with `node`, `ts-node`, or `tsx`.

:::info[Prisma ORM v7 changes]

In Prisma ORM v7, seeding is only triggered explicitly via `npx prisma db seed`. In Prisma ORM v6 and earlier, the seed script also ran automatically after `prisma migrate dev` and `prisma migrate reset`.

:::

| Property | Type | Required | Default |
| ----------------- | -------- | -------- | ------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ const prisma = new PrismaClient().$extends({
})
```

### Automatic seeding during migrations has been removed

In Prisma ORM v6 and earlier, running `prisma migrate dev` or `prisma migrate reset` would automatically execute your seed script after applying migrations. This automatic seeding behavior has been removed in Prisma ORM v7.

To seed your database in v7, you must explicitly run:

```terminal
npx prisma db seed
```

### Various environment variables have been removed

We've removed a small selection of Prisma-specific environment variables.
Expand Down
Loading