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

Show the Prisma ORM migration path and pending status.

Location: CLI > migration status

The database stores a marker, a row that says which version of your contract it currently matches. `migration status` compares that marker with a target version and lists the migrations in between. The target is the contract you last ran `contract emit` on, unless `--to` names another.

Use it before and after [`db migrate`](/guides/orm-db-migrate), and when debugging why an environment is not at the expected contract state.

## Usage

#### bun

```bash
bunx prisma migration status --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm prisma migration status --db "$DATABASE_URL"
```

#### yarn

```bash
yarn prisma migration status --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma migration status --db "$DATABASE_URL"
```

## Options

| Option              | What it does                                                                                                           |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `--db <url>`        | Connects to the database.                                                                                              |
| `--space <id>`      | Narrows output to a single contract space.                                                                             |
| `--to <contract>`   | Sets the target contract reference (hash, prefix, ref name, migration directory name, `<dir>^`, or `./path`).          |
| `--from <contract>` | Sets the origin contract reference. With `--from`, the command computes the path offline and does not need a database. |
| `--legend`          | Prints a key for the tree glyphs and lane colors.                                                                      |
| `--ascii`           | Uses ASCII glyphs (pipe-friendly).                                                                                     |
| `--config <path>`   | Read this config file instead of `./prisma.config.ts`.                                                                 |
| `--json`            | Prints a machine-readable result.                                                                                      |

## Examples

#### bun

```bash
bunx prisma migration status --db "$DATABASE_URL"
bunx prisma migration status --to production
bunx prisma migration status --from abc123 --to production
bunx prisma migration status --ascii
```

#### pnpm

```bash
pnpm prisma migration status --db "$DATABASE_URL"
pnpm prisma migration status --to production
pnpm prisma migration status --from abc123 --to production
pnpm prisma migration status --ascii
```

#### yarn

```bash
yarn prisma migration status --db "$DATABASE_URL"
yarn prisma migration status --to production
yarn prisma migration status --from abc123 --to production
yarn prisma migration status --ascii
```

#### npm

```bash
npx prisma migration status --db "$DATABASE_URL"
npx prisma migration status --to production
npx prisma migration status --from abc123 --to production
npx prisma migration status --ascii
```

## Reading the result

With `--db`, status reads the marker from the database and compares it with the target. With `--from`, it starts from the state you name instead and needs no database.

With `--json`, the command prints one `"kind": "result"` line. Inside its `envelope`:

- `result.summary` is the sentence the human output ends with, such as `Up to date` or a count of pending migrations.
- `result.spaces[].migrations[]` lists each migration on disk with a `status`: `pending` (on the way to the target, not yet applied), `applied` (on the way to the target, already applied), or `null` (not on the way to the target).
- `diagnostics[]`, beside `result` rather than inside it, lists each problem found. Each entry has a `code`, for example `MIGRATION.MARKER_NOT_IN_HISTORY`, a `summary`, and a `severity`, which this command always sets to `warn`.

The exit code is 0 even when `diagnostics` is not empty. A non-zero exit code means the command itself failed, for example with `MIGRATION.REF_NOT_FOUND` when `--to` names a ref that does not exist.

The `migration` group has three more read-only views: `migration graph` draws the chain of migrations, `migration log` lists what has run, and `migration list` lists the migrations on disk. Run each with `--help` for details.

Use [`db verify`](/guides/orm-db-verify) after applying migrations to check the final database shape against the emitted contract.

## Related pages

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

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
