# migration plan (/docs/cli/migration-plan)

> For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

Plan an on-disk migration from Prisma 8 contract changes.

Location: CLI > migration plan

`migration plan` compares the emitted contract against a starting contract and produces a new migration package with the required operations.

The starting contract is the [ref](https://www.prisma.io/docs/cli/migration-ref) named `db` when one exists, or whatever `--from` names. With neither, the plan starts from nothing and contains the full `CREATE` operations for the whole contract, so keep the `db` ref pointing at the migration your database is on (apply with [`db migrate --advance-ref db`](https://www.prisma.io/docs/cli/db-migrate) to move it automatically), or pass `--from` explicitly.

The command is offline. It does not need a database connection.

## Usage [#usage]

  

#### bun

```bash
bunx prisma@latest migration plan --name add-users-table
```

#### pnpm

```bash
pnpm dlx prisma@latest migration plan --name add-users-table
```

#### yarn

```bash
yarn dlx prisma@latest migration plan --name add-users-table
```

#### npm

```bash
npx prisma@latest migration plan --name add-users-table
```

## Options [#options]

| Option              | What it does                                                                                                                                                  |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--name <slug>`     | Sets the migration directory name suffix.                                                                                                                     |
| `--from <contract>` | Uses a specific starting contract reference (hash, prefix, ref name, migration directory name, `<dir>^`, or `./path`) instead of the latest migration target. |
| `--to <contract>`   | Sets the destination contract reference. Defaults to the emitted contract. Same grammar as `--from`.                                                          |
| `--config <path>`   | Read this config file instead of `./prisma.config.ts`.                                                                                                        |
| `--json`            | Prints a machine-readable result.                                                                                                                             |

## Recommended flow [#recommended-flow]

  

#### bun

```bash
bunx prisma@latest contract emit
bunx prisma@latest migration plan --name add-users-table
bunx prisma@latest migration show <migration-dir>
```

#### pnpm

```bash
pnpm dlx prisma@latest contract emit
pnpm dlx prisma@latest migration plan --name add-users-table
pnpm dlx prisma@latest migration show <migration-dir>
```

#### yarn

```bash
yarn dlx prisma@latest contract emit
yarn dlx prisma@latest migration plan --name add-users-table
yarn dlx prisma@latest migration show <migration-dir>
```

#### npm

```bash
npx prisma@latest contract emit
npx prisma@latest migration plan --name add-users-table
npx prisma@latest migration show <migration-dir>
```

Review the generated migration package before applying it with [`db migrate`](https://www.prisma.io/docs/cli/db-migrate).

## Planning a rollback [#planning-a-rollback]

Because `--to` accepts `<dir>^` (the source contract of a migration), you can plan a migration that walks back a change:

  

#### bun

```bash
bunx prisma@latest migration plan --to <migration-dir>^ --name rollback
```

#### pnpm

```bash
pnpm dlx prisma@latest migration plan --to <migration-dir>^ --name rollback
```

#### yarn

```bash
yarn dlx prisma@latest migration plan --to <migration-dir>^ --name rollback
```

#### npm

```bash
npx prisma@latest migration plan --to <migration-dir>^ --name rollback
```

## When to use migration plan [#when-to-use-migration-plan]

Use `migration plan` when your team wants database changes reviewed in version control. For local prototypes where review is not needed, [`db update`](https://www.prisma.io/docs/cli/db-update) is usually faster.

If the generated migration is not the migration you want, use [`migration new`](https://www.prisma.io/docs/cli/migration-new) and author the migration manually.

## Related pages

- [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions.
- [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project.
- [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets.
- [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma 8 CLI commands with prisma.config.ts and global flags.
- [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma 8 contract artifacts.