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

Verify a database against the current Prisma ORM contract.

Location: CLI > db verify

`db verify` checks whether the database marker and live schema match your emitted contract. It verifies the marker first, then checks the schema.

Use it in CI and deployment checks before application code that depends on a contract reaches users.

## Usage

#### bun

```bash
bunx prisma db verify --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm prisma db verify --db "$DATABASE_URL"
```

#### yarn

```bash
yarn prisma db verify --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma db verify --db "$DATABASE_URL"
```

## Options

| Option            | What it does                                                                |
| ----------------- | --------------------------------------------------------------------------- |
| `--db <url>`      | Connects to the database.                                                   |
| `--marker-only`   | Checks only the database marker.                                            |
| `--schema-only`   | Checks only whether the live schema satisfies the contract.                 |
| `--strict`        | Fails if the database includes schema elements not present in the contract. |
| `--config <path>` | Read this config file instead of `./prisma.config.ts`.                      |
| `--json`          | Prints machine-readable output.                                             |

## Exit codes

| Code | Meaning                                                                                        |
| ---- | ---------------------------------------------------------------------------------------------- |
| `0`  | The database matches the contract.                                                             |
| `2`  | The check could not run: conflicting mode flags, no emitted contract, or unreachable database. |
| `4`  | Drift or a marker finding.                                                                     |

## Examples

#### bun

```bash
bunx prisma db verify --db "$DATABASE_URL"
bunx prisma db verify --db "$DATABASE_URL" --strict
bunx prisma db verify --db "$DATABASE_URL" --schema-only
bunx prisma db verify --db "$DATABASE_URL" --marker-only
```

#### pnpm

```bash
pnpm prisma db verify --db "$DATABASE_URL"
pnpm prisma db verify --db "$DATABASE_URL" --strict
pnpm prisma db verify --db "$DATABASE_URL" --schema-only
pnpm prisma db verify --db "$DATABASE_URL" --marker-only
```

#### yarn

```bash
yarn prisma db verify --db "$DATABASE_URL"
yarn prisma db verify --db "$DATABASE_URL" --strict
yarn prisma db verify --db "$DATABASE_URL" --schema-only
yarn prisma db verify --db "$DATABASE_URL" --marker-only
```

#### npm

```bash
npx prisma db verify --db "$DATABASE_URL"
npx prisma db verify --db "$DATABASE_URL" --strict
npx prisma db verify --db "$DATABASE_URL" --schema-only
npx prisma db verify --db "$DATABASE_URL" --marker-only
```

Use JSON output in automation:

#### bun

```bash
bunx prisma db verify --db "$DATABASE_URL" --json
```

#### pnpm

```bash
pnpm prisma db verify --db "$DATABASE_URL" --json
```

#### yarn

```bash
yarn prisma db verify --db "$DATABASE_URL" --json
```

#### npm

```bash
npx prisma db verify --db "$DATABASE_URL" --json
```

## What failures mean

| Failure            | Meaning                                                                                      |
| ------------------ | -------------------------------------------------------------------------------------------- |
| Marker mismatch    | The database was not signed for the emitted contract, or the contract changed after signing. |
| Schema mismatch    | The live database does not satisfy the emitted contract.                                     |
| Strict mismatch    | The database has extra schema elements not present in the contract.                          |
| Extension mismatch | The contract requires an extension that is not wired in the config.                          |

Fix the database or contract, emit again if needed, then verify again.

## How PostgreSQL defaults are compared

When a column default is a literal value, `db verify` reads it as a value before it compares it with your contract, so the casts PostgreSQL adds when it prints the default do not cause a difference. This covers numbers such as `'-1'::integer` and `(5)::smallint`, text and enum values, including an enum value cast to a type in another PostgreSQL schema, `timestamp` values, `true`, `false`, `NULL`, JSON, and lists written as `'{...}'` or `ARRAY[...]`. `db verify` also recognizes `now()`, `clock_timestamp()`, `gen_random_uuid()`, and a sequence default, which it treats as `autoincrement()`.

Any other default is a SQL expression, which you write in your contract as a `sql` default, such as ``@default(sql`(now() + '00:03:00'::interval)`)``. [Default values](/guides/contract-authoring-psl-syntax#default-values) shows how to write one. `db verify` cannot work out whether two SQL expressions give the same value, so it compares their text, ignoring letter case and spaces. PostgreSQL often rewrites an expression when it stores it, for example by adding casts, so write a `sql` default in your contract the way PostgreSQL stores it. To see that form, run `npx prisma contract infer --output ./inferred.prisma` and copy the column's `@default` from that file.

Check constraints and the `WHERE` clause of a partial index are compared more strictly than `sql` defaults: their text must match exactly, including letter case and spaces.

If `db verify` reports a difference in a `timestamptz` value inside a check constraint or a partial index's `WHERE` clause, check whether your contract was inferred before `8.0.0-rc.12` from a server that was not set to UTC. `db verify` reads the database with the time zone set to UTC and dates in ISO format, whatever the server or your database role sets, so a value that your contract has in another time zone no longer matches as text. To fix it, copy the new text from a fresh `npx prisma contract infer --output ./inferred.prisma` into your contract, emit the contract, and run `db sign`.

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