7.10.0), the current stable release.
Prerequisites
- Node.js 20.19, 22.12, or 24 and later
- A ClickHouse Managed Postgres service
psql, to create the database. You can also run theCREATE DATABASEstatement in the SQL console.- On macOS: Docker, to run Prisma Migrate (see Run the migration)
Create a ClickHouse Managed Postgres service
In the ClickHouse Cloud console, click New service and select Postgres. The instance is ready in a few minutes. See the quickstart for a walkthrough.Get your connection details
Click Connect in the left sidebar of your service. The modal shows your username, password, server, and port, plus ready-made connection strings. This guide uses two connections, because Prisma has two components that talk to the database:- Your application (Prisma Client) connects via PgBouncer on port
6432. PgBouncer pools connections, so many app processes or serverless instances can share a small number of Postgres backends. - The Prisma CLI (Prisma Migrate) connects directly on port
5432. Prisma Migrate takes a session-level advisory lock while it runs. In PgBouncer’s transaction pooling mode, that lock can stay held on a pooled backend that then serves other clients, and later migrations block on it.
<service-name>-ca-certificate.pem. You also find it under Settings → CA Certificate. The certificate is unique to your instance, and you use it to connect with sslmode=verify-full, which checks that you’re talking to your own server.
Set up the project
Create a TypeScript project and install the Prisma CLI, Prisma Client, the node-postgres driver adapter, anddotenv:
Install
prisma@7 and @prisma/client@7 explicitly. At the time of writing, the npm latest tag of prisma points to a Prisma 8 release candidate, which uses a different setup from this guide.tsconfig.json:
Initialize Prisma
1
Run prisma init
prisma/schema.prisma and the Prisma config file prisma7.config.ts, adds a placeholder DATABASE_URL to .env and the generated client to .gitignore (creating either file if needed), and adds Prisma skills for AI coding agents. Prisma 7.10 and later name the config file prisma7.config.ts so that it doesn’t clash with the Prisma 8 format.2
Add the CA certificate
Move the CA certificate you downloaded into the project root and rename it to Relative certificate paths are resolved from the directory you run commands in, so run all commands in this guide from the project root.
ca-certificate.pem:Configure the connection
1
Create a database
Create a database for the app. Replace
<PASSWORD> and the host with the values from the Connect modal:2
Set the connection URLs
In The two URLs use different TLS parameters because they’re read by different drivers:
.env, replace the placeholder DATABASE_URL that prisma init added with these two connection URLs, which both point at the guide_prisma database. Use the password from the Connect modal:DATABASE_URLis read by node-postgres through@prisma/adapter-pg. It supports the standardsslmode=verify-full&sslrootcert=...parameters, the same ones shown in the Connect modal.DIRECT_URLis read by the Prisma CLI’s schema engine, which has its own parameters:sslcertis the path to the CA certificate, andsslaccept=strictturns on certificate and hostname verification.
3
Point the Prisma CLI at the direct connection
Replace the contents of In Prisma 7, the URL in the config file is used only by the CLI. Prisma Client gets its connection from the driver adapter, which you configure in Query the database.
prisma7.config.ts:Define the schema and run the migration
1
Add a model
Add a
Todo model to the end of prisma/schema.prisma:2
Run the migration
On Linux, run Prisma Migrate directly:On macOS, run the same command in a Linux container:Prisma creates the SQL migration in
prisma/migrations/ and applies it:3
Generate Prisma Client
generated/prisma. This command doesn’t connect to the database, so you can run it on any platform.Query the database
1
Create the Prisma Client
Create
lib/prisma.ts. The PrismaPg adapter connects with DATABASE_URL, through PgBouncer:2
Run CRUD queries
Create Run it:
script.ts:3
Serve the data over HTTP
Create Start the server:In a second terminal, add two todos:Open http://localhost:3000/todos in your browser to see them. The response looks like this:
server.ts, a minimal HTTP server that creates todos with POST /todos and lists them on any GET request:Verify in the SQL console
In the ClickHouse Cloud console, open SQL console for your service, expand your database and thepublic schema, and select the Todo table. You also see the _prisma_migrations table, where Prisma Migrate records applied migrations.
The Todo table contains the two rows you added through the HTTP endpoint:
Troubleshooting
Next steps
- Connection: connection strings, PgBouncer, and TLS
- Settings: tune Postgres and PgBouncer parameters
- Read replicas: scale read-heavy workloads
- Local development: develop against a local Postgres in Docker
- Prisma Migrate in production: use
prisma migrate deployin your CI pipeline