PostgreSQL extensions

Enable and use PostgreSQL extensions with Prisma Postgres.

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

Enabling an extension

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.

Using extensions with Prisma ORM

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.

Here's a walkthrough using pgvector as an example.

1. Create an empty migration

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.

2. Add the extension and table to your migration

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
);

3. Apply the migration

npx prisma migrate deploy

4. Pull the table into your Prisma schema

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

npx prisma db pull

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")?
}

5. Query with raw SQL

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.

Supported extensions

View all supported extensions

Don't see what you need? Request an extension.

Limitations

  • 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.
  • PostGIS is not yet supported. Support is coming soon.

On this page