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

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

Initialize a database from the current Prisma 8 contract.

Location: CLI > db init

`db init` bootstraps a database to match the current emitted contract and signs it.

It creates everything the contract declares and the database does not have yet, using additive operations only. Structures already in place and compatible are left alone. A conflict that would need a destructive change stops the run.

## Usage [#usage]

  

#### bun

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

#### pnpm

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

#### yarn

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

#### npm

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

## Options [#options]

| Option                 | What it does                                                                    |
| ---------------------- | ------------------------------------------------------------------------------- |
| `--db <url>`           | Connects to the database.                                                       |
| `--dry-run`            | Shows planned operations without applying them.                                 |
| `--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.                                               |

## Behavior [#behavior]

`db init` is intended for bootstrap work. It creates missing structures needed by the contract and writes the contract marker after the database matches.

Run a dry run first when you are not working with a disposable local database:

  

#### bun

```bash
bunx prisma@latest db init --db "$DATABASE_URL" --dry-run
```

#### pnpm

```bash
pnpm dlx prisma@latest db init --db "$DATABASE_URL" --dry-run
```

#### yarn

```bash
yarn dlx prisma@latest db init --db "$DATABASE_URL" --dry-run
```

#### npm

```bash
npx prisma@latest db init --db "$DATABASE_URL" --dry-run
```

## Examples [#examples]

  

#### bun

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

#### pnpm

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

#### npm

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

  

#### bun

```bash
bunx prisma@latest db init --db "$DATABASE_URL" --dry-run --json
```

#### pnpm

```bash
pnpm dlx prisma@latest db init --db "$DATABASE_URL" --dry-run --json
```

#### yarn

```bash
yarn dlx prisma@latest db init --db "$DATABASE_URL" --dry-run --json
```

#### npm

```bash
npx prisma@latest db init --db "$DATABASE_URL" --dry-run --json
```

## When to use db update instead [#when-to-use-db-update-instead]

Use [`db update`](https://www.prisma.io/docs/cli/db-update) when the database already exists and you want Prisma 8 to reconcile it with a changed contract. Use [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) when you want a reviewable migration package in version control.

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