Prisma 8 is here.Read the docs

db init

Initialize a database from the current Prisma 8 contract.

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

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

Options

OptionWhat it does
--db <url>Connects to the database.
--dry-runShows planned operations without applying them.
--advance-ref <name>Advances the named ref to the post-command contract hash.
--config <path>Read this config file instead of ./prisma.config.ts.
--jsonPrints a machine-readable result.

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:

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

Examples

bunx prisma@latest contract emit
bunx prisma@latest db init --db "$DATABASE_URL"
bunx prisma@latest db verify --db "$DATABASE_URL"
bunx prisma@latest db init --db "$DATABASE_URL" --dry-run --json

When to use db update instead

Use db update when the database already exists and you want Prisma 8 to reconcile it with a changed contract. Use migration plan when you want a reviewable migration package in version control.

On this page