Builder's DayOctober 26 · SFGet tickets

Prisma 8 extension

PostgreSQL

PostgreSQL support for Prisma ORM: config, runtime, contract authoring, and migrations in one package.

By PrismaPostgreSQL

What it does

The one package a PostgreSQL application installs. It wires the SQL family, the PostgreSQL target, adapter, and driver into defineConfig and the postgres() runtime, and ships a serverless entrypoint for per-request runtimes such as Cloudflare Workers and AWS Lambda. Every other PostgreSQL extension plugs into this one.

Configure the database

prisma.config.ts
import { definePrismaConfig } from 'prisma/config';
import { defineConfig as ormConfig } from '@prisma/orm-postgres/config';

export default definePrismaConfig({
  orm: ormConfig({
    contract: './src/prisma/contract.prisma',
    db: {
      connection: process.env['DATABASE_URL']!,
    },
  }),
});

Create the client

src/prisma/db.ts
import postgres from '@prisma/orm-postgres/runtime';
import type { Contract } from './contract.d';
import contractJson from './contract.json' with { type: 'json' };

export const db = postgres<Contract>({
  contractJson,
  url: process.env['DATABASE_URL']!,
});