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

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

Sign a database with the current Prisma 8 contract.

Location: CLI > db sign

`db sign` verifies that the live database satisfies the emitted contract and, if so, writes or updates the database signature. The signature records that this database instance is aligned with a specific contract version.

It is idempotent and safe to run in CI or a deployment pipeline. Use it after importing or inferring an existing schema, or after a deployment flow that already applied the required database changes.

## Usage [#usage]

  

#### bun

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

#### pnpm

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

#### yarn

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

#### npm

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

## Options [#options]

| Argument or option      | What it does                                                                                                                       |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `[contract]`            | Signs against a specific contract reference (hash, prefix, ref name, or migration directory name) instead of the emitted contract. |
| `--db <url>`            | Connects to the database.                                                                                                          |
| `--contract <contract>` | The contract reference as a flag. Also accepts the `<dir>^` and `./path` forms that the positional argument does not.              |
| `--config <path>`       | Read this config file instead of `./prisma.config.ts`.                                                                             |
| `--json`                | Prints a machine-readable result.                                                                                                  |

## Exit codes [#exit-codes]

| Code | Meaning                                                                                                   |
| ---- | --------------------------------------------------------------------------------------------------------- |
| `0`  | The database was signed.                                                                                  |
| `2`  | The command could not run: unresolvable contract reference, no emitted contract, or unreachable database. |
| `4`  | Schema verification failed and no signature was written.                                                  |

## Example [#example]

  

#### bun

```bash
bunx prisma@latest contract emit
bunx prisma@latest db sign --db "$DATABASE_URL"
bunx prisma@latest db verify --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm dlx prisma@latest contract emit
pnpm dlx prisma@latest db sign --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 sign --db "$DATABASE_URL"
yarn dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma@latest contract emit
npx prisma@latest db sign --db "$DATABASE_URL"
npx prisma@latest db verify --db "$DATABASE_URL"
```

## When to use it [#when-to-use-it]

Use `db sign` only after you believe the live database already matches the emitted contract. It is common after:

* `contract infer` for a brownfield database
* a manually reviewed migration flow
* a database restore that you need to mark as matching the current contract

Do not use `db sign` to hide drift. If verification fails, fix the contract or database first.

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