Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Extensions

Prisma Postgres supports standard PostgreSQL extensions. Extensions add functionality such as vector search, full-text search, fuzzy matching, and cryptographic functions to your database.

Enable any supported extension using standard SQL:

CREATE EXTENSION IF NOT EXISTS vector;

This works from any PostgreSQL client: psql, a GUI like TablePlus, a migration file, or a raw SQL query from your application.

The plpgsql extension is enabled by default on all Prisma Postgres instances.

Prisma ORM doesn't natively support all extension types yet. For extensions that introduce custom types (like vector from pgvector), you can use customized migrations and raw SQL or TypedSQL to work with them.

The following walkthrough uses pgvector as an example.

title="bun"
bunx prisma migrate dev --name add-pgvector --create-only
pnpm
pnpm prisma migrate dev --name add-pgvector --create-only
yarn
yarn prisma migrate dev --name add-pgvector --create-only
npm
npx prisma migrate dev --name add-pgvector --create-only

The --create-only flag creates the migration file without applying it, so you can add custom SQL first.

Edit the generated migration file to enable the extension and create your table:

-- prisma/migrations/<timestamp>-add-pgvector/migration.sql

CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE "Document" (

  id SERIAL PRIMARY KEY,

  title TEXT NOT NULL,

  embedding VECTOR(4) -- dimensions depend on your embedding model

);
title="bun"
bunx prisma migrate deploy
pnpm
pnpm prisma migrate deploy
yarn
yarn prisma migrate deploy
npm
npx prisma migrate deploy

Introspect your database to update your Prisma schema with the new table:

bunx prisma db pull
Bash
pnpm prisma db pull
Bash
yarn prisma db pull
Bash
npx prisma db pull

Because Prisma ORM doesn't natively support the VECTOR type, it will be represented as Unsupported:

prisma
model Document {
  id        Int                    @id @default(autoincrement())
  title     String
  embedding Unsupported("vector")?
}

Because Prisma ORM doesn't natively support the VECTOR type, it will be represented as Unsupported:

model Document {

  id        Int                    @id @default(autoincrement())

  title     String

  embedding Unsupported("vector")?

}

Use $executeRaw or $queryRaw to interact with extension-specific types:

await prisma.$executeRaw`

  INSERT INTO "Document" (title, embedding)

  VALUES ('My Title', '[1,22,1,42]'::vector)

`;

You can also use TypedSQL for type-safe queries.

View all supported extensions

If you need an extension that is not listed, request an extension.

  • Prisma Studio does not support tables that use custom types from extensions (e.g., VECTOR). Queries against those tables will return a deserialization error.
  • Prisma ORM does not natively support all extension types. Custom types are represented as Unsupported in your schema and must be queried with raw SQL.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu