Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

PostgreSQL extensions

This page is about PostgreSQL extensions and explains how to use them with Prisma ORM.

PostgreSQL allows you to extend your database functionality by installing and activating packages known as extensions. For example, the citext extension adds a case-insensitive string data type. Some extensions, such as citext, are supplied directly by PostgreSQL, while other extensions are developed externally. For more information on extensions, see the PostgreSQL documentation.

To use an extension, it must first be installed on the local file system of your database server. You then need to activate the extension, which runs a script file that adds the new functionality.

The following example installs the citext extension.

Run the following command to create an empty migration that you can customize:

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

In the new migration file that was created in the migrations directory, add the following statement:

CREATE EXTENSION IF NOT EXISTS citext;

Run the following command to deploy the migration and apply to your database:

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

You can now use the extension in your queries with Prisma Client. If the extension has special data types that currently can't be natively represented in the Prisma schema, you can still define fields of that type on your models using the Unsupported fallback type.

Suggest an edit

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

Export
Documentation menu