# Extensions

Prisma Postgres supports standard [PostgreSQL extensions](https://www.postgresql.org/docs/current/sql-createextension.html). Extensions add functionality such as vector search, full-text search, fuzzy matching, and cryptographic functions to your database.

## [Enabling an extension](#enabling-an-extension)

Enable any [supported extension](#supported-extensions) 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](#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](/guides/prisma-migrate-v7-workflows-customizing-migrations) and [raw SQL](/guides/prisma-client-v7-using-raw-sql) or [TypedSQL](/guides/prisma-client-v7-using-raw-sql-typedsql) to work with them.

The following walkthrough uses pgvector as an example.

### [1. Create an empty migration](#1-create-an-empty-migration)

:::code-group
```title="bun"
bunx prisma migrate dev --name add-pgvector --create-only
```

```bash title="pnpm"
pnpm prisma migrate dev --name add-pgvector --create-only
```

```bash title="yarn"
yarn prisma migrate dev --name add-pgvector --create-only
```

```bash title="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.

### [2. Add the extension and table to your migration](#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](#3-apply-the-migration)

:::code-group
```title="bun"
bunx prisma migrate deploy
```

```bash title="pnpm"
pnpm prisma migrate deploy
```

```bash title="yarn"
yarn prisma migrate deploy
```

```bash title="npm"
npx prisma migrate deploy
```
:::

### [4. Pull the table into your Prisma schema](#4-pull-the-table-into-your-prisma-schema)

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

::::tabs
:::tab{title="bun"}
```
bunx prisma db pull
```
:::

:::tab{title="pnpm"}
```bash
pnpm prisma db pull
```
:::

:::tab{title="yarn"}
```bash
yarn prisma db pull
```
:::

:::tab{title="npm"}
```bash
npx prisma db pull
```

Because Prisma ORM doesn't natively support the `VECTOR` type, it will be represented as [`Unsupported`](/guides/prisma-schema-v7-data-model-models#unsupported-types):

```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`](/guides/prisma-schema-v7-data-model-models#unsupported-types):

```
model Document {

  id        Int                    @id @default(autoincrement())

  title     String

  embedding Unsupported("vector")?

}
```

### [5. Query with raw SQL](#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](/guides/prisma-client-v7-using-raw-sql-typedsql) for type-safe queries.

## [Supported extensions](#supported-extensions)

:::accordion{title="View all supported extensions"}
- [`amcheck`](https://www.postgresql.org/docs/current/amcheck.html)
- [`autoinc`](https://www.postgresql.org/docs/current/contrib-spi.html)
- [`bloom`](https://www.postgresql.org/docs/current/bloom.html)
- [`btree_gin`](https://www.postgresql.org/docs/current/btree-gin.html)
- [`btree_gist`](https://www.postgresql.org/docs/current/btree-gist.html)
- [`citext`](https://www.postgresql.org/docs/current/citext.html)
- [`cube`](https://www.postgresql.org/docs/current/cube.html)
- [`dblink`](https://www.postgresql.org/docs/current/dblink.html)
- [`dict_int`](https://www.postgresql.org/docs/current/dict-int.html)
- [`dict_xsyn`](https://www.postgresql.org/docs/current/dict-xsyn.html)
- [`earthdistance`](https://www.postgresql.org/docs/current/earthdistance.html)
- [`file_fdw`](https://www.postgresql.org/docs/current/file-fdw.html)
- [`fuzzystrmatch`](https://www.postgresql.org/docs/current/fuzzystrmatch.html)
- [`hstore`](https://www.postgresql.org/docs/current/hstore.html)
- [`insert_username`](https://www.postgresql.org/docs/current/contrib-spi.html)
- [`intagg`](https://www.postgresql.org/docs/current/intagg.html)
- [`intarray`](https://www.postgresql.org/docs/current/intarray.html)
- [`isn`](https://www.postgresql.org/docs/current/isn.html)
- [`lo`](https://www.postgresql.org/docs/current/lo.html)
- [`ltree`](https://www.postgresql.org/docs/current/ltree.html)
- [`moddatetime`](https://www.postgresql.org/docs/current/contrib-spi.html)
- [`pageinspect`](https://www.postgresql.org/docs/current/pageinspect.html)
- [`pg_buffercache`](https://www.postgresql.org/docs/current/pgbuffercache.html)
- [`pg_freespacemap`](https://www.postgresql.org/docs/current/pgfreespacemap.html)
- [`pg_prewarm`](https://www.postgresql.org/docs/current/pgprewarm.html)
- [`pg_search`](https://pgxn.org/dist/pg_search/)
- [`pg_stat_statements`](https://www.postgresql.org/docs/current/pgstatstatements.html)
- [`pg_surgery`](https://www.postgresql.org/docs/current/pgsurgery.html)
- [`pg_trgm`](https://www.postgresql.org/docs/current/pgtrgm.html)
- [`pg_visibility`](https://www.postgresql.org/docs/current/pgvisibility.html)
- [`pg_walinspect`](https://www.postgresql.org/docs/current/pgwalinspect.html)
- [`pgcrypto`](https://www.postgresql.org/docs/current/pgcrypto.html)
- [`pgrowlocks`](https://www.postgresql.org/docs/current/pgrowlocks.html)
- [`pgstattuple`](https://www.postgresql.org/docs/current/pgstattuple.html)
- [`plpgsql`](https://www.postgresql.org/docs/current/plpgsql.html) _(enabled by default)_
- [`postgres_fdw`](https://www.postgresql.org/docs/current/postgres-fdw.html)
- [`refint`](https://www.postgresql.org/docs/current/contrib-spi.html)
- [`seg`](https://www.postgresql.org/docs/current/seg.html)
- [`sslinfo`](https://www.postgresql.org/docs/current/sslinfo.html)
- [`tablefunc`](https://www.postgresql.org/docs/current/tablefunc.html)
- [`tcn`](https://www.postgresql.org/docs/current/tcn.html)
- [`tsm_system_rows`](https://www.postgresql.org/docs/current/tsm-system-rows.html)
- [`tsm_system_time`](https://www.postgresql.org/docs/current/tsm-system-time.html)
- [`unaccent`](https://www.postgresql.org/docs/current/unaccent.html)
- [`uuid-ossp`](https://www.postgresql.org/docs/current/uuid-ossp.html)
- [`vector`](https://github.com/pgvector/pgvector)
- [`xml2`](https://www.postgresql.org/docs/current/xml2.html)
:::

If you need an extension that is not listed, [request an extension](https://pris.ly/i-want-extensions).

## [Limitations](#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`](/guides/prisma-schema-v7-data-model-models#unsupported-types) in your schema and must be queried with [raw SQL](/guides/prisma-client-v7-using-raw-sql).

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
