# db migrate (/docs/cli/db-migrate)

> 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.

Apply pending Prisma 8 migrations.

Location: CLI > db migrate

`db migrate` applies pending on-disk migrations to advance the database. It walks every contract space (app and extensions) and applies migrations in canonical order: extensions alphabetically, then the app. It applies only the migrations that exist on disk and never generates new operations.

Use it from a controlled deployment step after reviewing migration packages.

## Usage [#usage]

  

#### bun

```bash
bunx prisma@latest db migrate --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm dlx prisma@latest db migrate --db "$DATABASE_URL"
```

#### yarn

```bash
yarn dlx prisma@latest db migrate --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma@latest db migrate --db "$DATABASE_URL"
```

## Options [#options]

| Option                 | What it does                                                                                                                                                           |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--db <url>`           | Connects to the database.                                                                                                                                              |
| `--to <contract>`      | Applies migrations up to a target contract (hash, prefix, ref name, migration directory name, `<dir>^`, or `./path`).                                                  |
| `--advance-ref <name>` | Advances the named [ref](https://www.prisma.io/docs/cli/migration-ref) to the post-apply marker after success.                                                                                   |
| `--show`               | Previews the migration route without applying (read-only).                                                                                                             |
| `--from <contract>`    | Sets the from-state for the `--show` preview: `@contract` (the emitted contract), `@db` (the database's current marker), a hash, a ref name, or a migration directory. |
| `--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 migration status --db "$DATABASE_URL"
bunx prisma@latest db migrate --db "$DATABASE_URL"
bunx prisma@latest migration status --db "$DATABASE_URL"
bunx prisma@latest db verify --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm dlx prisma@latest migration status --db "$DATABASE_URL"
pnpm dlx prisma@latest db migrate --db "$DATABASE_URL"
pnpm dlx prisma@latest migration status --db "$DATABASE_URL"
pnpm dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### yarn

```bash
yarn dlx prisma@latest migration status --db "$DATABASE_URL"
yarn dlx prisma@latest db migrate --db "$DATABASE_URL"
yarn dlx prisma@latest migration status --db "$DATABASE_URL"
yarn dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma@latest migration status --db "$DATABASE_URL"
npx prisma@latest db migrate --db "$DATABASE_URL"
npx prisma@latest migration status --db "$DATABASE_URL"
npx prisma@latest db verify --db "$DATABASE_URL"
```

Run `migration status` before and after applying migrations to see what changed.

## Previewing the route [#previewing-the-route]

`--show` prints the route `db migrate` would take without touching the database:

  

#### bun

```bash
bunx prisma@latest db migrate --show
bunx prisma@latest db migrate --show --from @contract --to production
```

#### pnpm

```bash
pnpm dlx prisma@latest db migrate --show
pnpm dlx prisma@latest db migrate --show --from @contract --to production
```

#### yarn

```bash
yarn dlx prisma@latest db migrate --show
yarn dlx prisma@latest db migrate --show --from @contract --to production
```

#### npm

```bash
npx prisma@latest db migrate --show
npx prisma@latest db migrate --show --from @contract --to production
```

## Applying to a target [#applying-to-a-target]

If your project uses named [refs](https://www.prisma.io/docs/cli/migration-ref), apply up to a target ref:

  

#### bun

```bash
bunx prisma@latest db migrate --db "$DATABASE_URL" --to production
```

#### pnpm

```bash
pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" --to production
```

#### yarn

```bash
yarn dlx prisma@latest db migrate --db "$DATABASE_URL" --to production
```

#### npm

```bash
npx prisma@latest db migrate --db "$DATABASE_URL" --to production
```

Manage refs with [`migration ref`](https://www.prisma.io/docs/cli/migration-ref).

## 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.