apps/docs/content/docs/postgres/database/postgres-extensions.mdx
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.
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.
Here's a walkthrough using pgvector as an example.
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
);
npx prisma migrate deploy
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")?
}
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.
amcheckautoincbloombtree_ginbtree_gistcitextcubedblinkdict_intdict_xsynearthdistancefile_fdwfuzzystrmatchhstoreinsert_usernameintaggintarrayisnloltreemoddatetimepageinspectpg_buffercachepg_freespacemappg_prewarmpg_searchpg_stat_statementspg_surgerypg_trgmpg_visibilitypg_walinspectpgcryptopgrowlockspgstattupleplpgsql (enabled by default)postgres_fdwrefintsegsslinfotablefunctcntsm_system_rowstsm_system_timeunaccentuuid-osspvectorxml2Don't see what you need? Request an extension.
VECTOR). Queries against those tables will return a deserialization error.Unsupported in your schema and must be queried with raw SQL.