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

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

Update a database to match the current Prisma 8 contract.

Location: CLI > db update

`db update` compares the live database with the emitted contract and applies the changes that close the gap, whether or not the database was bootstrapped with `db init`.

Use it for direct reconciliation when you do not need a checked-in migration package.

## Usage [#usage]

  

#### bun

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

#### pnpm

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

#### yarn

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

#### npm

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

## Options [#options]

| Option                 | What it does                                                                                    |
| ---------------------- | ----------------------------------------------------------------------------------------------- |
| `--db <url>`           | Connects to the database.                                                                       |
| `--dry-run`            | Shows planned operations without applying them.                                                 |
| `--to <contract>`      | Updates to a specific contract (hash, prefix, ref name, migration directory name, or `./path`). |
| `--advance-ref <name>` | Advances the named [ref](https://www.prisma.io/docs/cli/migration-ref) to the post-command contract hash.                 |
| `--config <path>`      | Read this config file instead of `./prisma.config.ts`.                                          |
| `--json`               | Prints a machine-readable result.                                                               |

## Destructive changes need consent [#destructive-changes-need-consent]

An operation that would destroy data is applied only with your consent: the command asks you to type the database name. In a CI job or a run with `--no-interactive`, where the command cannot ask, pass the consent as `--confirm <database>` instead:

  

#### bun

```bash
bunx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb
```

#### pnpm

```bash
pnpm dlx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb
```

#### yarn

```bash
yarn dlx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb
```

#### npm

```bash
npx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb
```

## Recommended flow [#recommended-flow]

  

#### bun

```bash
bunx prisma@latest contract emit
bunx prisma@latest db update --db "$DATABASE_URL" --dry-run
bunx prisma@latest db update --db "$DATABASE_URL"
bunx prisma@latest db verify --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm dlx prisma@latest contract emit
pnpm dlx prisma@latest db update --db "$DATABASE_URL" --dry-run
pnpm dlx prisma@latest db update --db "$DATABASE_URL"
pnpm dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### yarn

```bash
yarn dlx prisma@latest contract emit
yarn dlx prisma@latest db update --db "$DATABASE_URL" --dry-run
yarn dlx prisma@latest db update --db "$DATABASE_URL"
yarn dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma@latest contract emit
npx prisma@latest db update --db "$DATABASE_URL" --dry-run
npx prisma@latest db update --db "$DATABASE_URL"
npx prisma@latest db verify --db "$DATABASE_URL"
```

Use `--dry-run` before applying changes in shared environments.

## When to use migrations instead [#when-to-use-migrations-instead]

For reviewable database changes in version control, use [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) and [`db migrate`](https://www.prisma.io/docs/cli/db-migrate).

Use `db update` for local development, preview environments, and workflows where direct reconciliation is acceptable.

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