Prisma ORM 8 is here.Read the docs

Supported database features

The contract records which database features your packages support, so Prisma ORM can reject an unsupported one early with a clear error.

Your contract, the contract.prisma file that replaced schema.prisma, describes your data. npx prisma contract emit writes contract.json and contract.d.ts beside it. The capabilities section of contract.json lists the database features you can use, under keys such as sql.lateral. Prisma ORM writes that section, and you never edit it. If you use a feature that is not listed, Prisma ORM raises an error instead of sending the query to the database.

Where the capabilities section comes from

The keys come from your database package (@prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo) and any extension packages listed in prisma.config.ts. npx prisma contract emit never connects to your database. It reads those packages and writes what they report, in groups:

src/prisma/contract.json (excerpt)
{
  "capabilities": {
    "postgres": { "distinctOn": true, "pgvector.cosine": true },
    "sql": { "lateral": true, "scalarList": true }
  }
}

Error messages and the table below name a key group first, postgres.pgvector.cosine. The sql group holds keys that more than one SQL database may support. SQLite reports false for some of them. Keys under postgres belong to PostgreSQL only. Extension packages add keys of their own, and pgvector.cosine comes from the pgvector package. Install it with npm install @prisma/orm-extension-pgvector, list it in prisma.config.ts, and run npx prisma contract emit again:

prisma.config.ts
import "dotenv/config";
import { definePrismaConfig } from "prisma/config";
import pgvector from "@prisma/orm-extension-pgvector/control";
import { defineConfig as ormConfig } from "@prisma/orm-postgres/config";

export default definePrismaConfig({
  orm: ormConfig({
    contract: "./src/prisma/contract.prisma",
    extensions: [pgvector],
    db: { connection: process.env['DATABASE_URL']! },
  }),
});

pgvector is also a PostgreSQL server extension, and the package ships a migration that installs it. Apply it with npx prisma db migrate, see Using extensions. Run npx prisma contract emit after every change to the contract or to the extension list.

What the capabilities section controls

When the contract is built. If your contract uses a feature your database package does not support, npx prisma contract emit fails. SQLite has no scalarList key, so a list field such as tags String[] fails on SQLite:

Field "User.tags" is a scalar list, but target "sqlite" does not support
scalar lists (the adapter does not report the "scalarList" capability).
Remove the list or author it against a target that supports scalar lists.

In that message, both words mean your database package, and the message's "scalarList" is the sql.scalarList key. Do one of the two: remove the list field, or move to a database that supports list fields. To move to PostgreSQL, change the @prisma/orm-sqlite/config import and the connection string in prisma.config.ts, and create the new database.

When you call a method on the SQL query builder or on the ORM client. A method that needs a feature throws an error whose code is ORM.CAPABILITY_MISSING. The message names the method and the key:

distinctOn() requires capability postgres.distinctOn

That message means the method is not available on the database package you chose. Rewrite the query without it, or move to a database that supports the feature. If the key comes from an extension package, install that package and list it in prisma.config.ts. You do not have to run the query to get the error, so a test that only builds the query still fails. Your own code can read the same list through db, the client you create once in src/prisma/db.ts, which npx prisma orm init writes. A value such as db.contract.capabilities.sql?.lateral is true or false, or undefined if the whole group is missing. For a key with a dot in it, write db.contract.capabilities.postgres?.["pgvector.cosine"]:

if (db.contract.capabilities.sql?.lateral) {
  // run the lateral join here, or fall back to a second query
}

Example keys

A few of the keys your database package and extension packages supply:

KeyWhat it covers
sql.lateralLateral joins (lateralJoin())
sql.returningRETURNING clauses on writes
sql.scalarListList fields such as tags String[]
postgres.distinctOnDISTINCT ON queries (distinctOn())
postgres.pgvector.cosineCosine distance from the pgvector package

PostgreSQL reports true for all three sql keys above. SQLite reports false for sql.lateral, true for sql.returning, and has no sql.scalarList key at all. This table is a sample, not the full list. Open src/prisma/contract.json in your project to see every key you have. The MongoDB packages report no keys, so neither check applies on MongoDB. The ORM reference lists the methods each database has.

The capabilities section and prisma db verify

npx prisma db verify checks the live database against the contract's tables and columns, not against this section. The keys say what your packages support, recorded when you run npx prisma contract emit.

Prompt your coding agent

Projects created with npm create prisma@latest include the Prisma ORM skills for your coding agent. In an existing project, run npx prisma skills sync. The prisma-8 skill covers this material. Ask your agent to:

  • "Which keys in the capabilities section does our code rely on, and which package provides each?"
  • "Add pgvector to the project and confirm its key shows up in the emitted contract."

Next steps

On this page