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.
bunx prisma db verify --db "$DATABASE_URL"pnpm prisma db verify --db "$DATABASE_URL"yarn prisma db verify --db "$DATABASE_URL"npx prisma db verify --db "$DATABASE_URL"| 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. |
| 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. |
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-onlypnpm 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-onlyyarn 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-onlynpx 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-onlyUse JSON output in automation:
bunx prisma db verify --db "$DATABASE_URL" --jsonpnpm prisma db verify --db "$DATABASE_URL" --jsonyarn prisma db verify --db "$DATABASE_URL" --jsonnpx prisma db verify --db "$DATABASE_URL" --json| 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.
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 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.