Labsco
prisma logo

prisma-database-setup-cockroachdb

✓ Official8

by prisma · part of prisma/cursor-plugin

CockroachDB Setup. Reference when using this Prisma feature.

🔥🔥🔥✓ VerifiedFreeAdvanced setup
🧩 One of 7 skills in the prisma/cursor-plugin package — works on its own, and pairs well with its siblings.

CockroachDB Setup. Reference when using this Prisma feature.

Inspect the full instructions your agent will receiveExpand

This is the exact playbook injected into your agent when the skill activates — shown here so you can audit it before installing. You don't need to read it to use the skill.

by prisma

CockroachDB Setup. Reference when using this Prisma feature. npx skills add https://github.com/prisma/cursor-plugin --skill prisma-database-setup-cockroachdb Download ZIPGitHub8

3. Environment Variable

In .env:

Copy & paste — that's it
DATABASE_URL="postgresql://user:password@host:26257/db?sslmode=verify-full"

Note: CockroachDB uses the PostgreSQL wire protocol, so the URL often looks like postgresql, but the provider MUST be cockroachdb in the schema to handle specific CRDB features correctly.

Driver Adapter (Prisma ORM 7 required)

Prisma ORM 7 uses the query compiler by default, so you must use a driver adapter. CockroachDB is PostgreSQL-compatible, so use the PostgreSQL adapter.

Install adapter and driver:

Copy & paste — that's it
npm install @prisma/adapter-pg pg

Instantiate Prisma Client with the adapter:

Copy & paste — that's it
import 'dotenv/config'
import { PrismaClient } from '../generated/client'
import { PrismaPg } from '@prisma/adapter-pg'

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })

ID Generation

CockroachDB uses BigInt or UUID for IDs efficiently.

Copy & paste — that's it
model User {
 id BigInt @id @default(autoincrement()) // Uses unique_rowid()
}

Or using string UUIDs:

Copy & paste — that's it
model User {
 id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
}