
prisma-database-setup-cockroachdb
✓ Official★ 8by prisma · part of prisma/cursor-plugin
CockroachDB Setup. Reference when using this Prisma feature.
CockroachDB Setup. Reference when using this Prisma feature.
Inspect the full instructions your agent will receiveExpandCollapse
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:
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:
npm install @prisma/adapter-pg pg
Instantiate Prisma Client with the adapter:
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.
model User {
id BigInt @id @default(autoincrement()) // Uses unique_rowid()
}
Or using string UUIDs:
model User {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
}
npm install @prisma/adapter-pg pgRun this in your project — your agent picks the skill up automatically.
CockroachDB Setup
Configure Prisma with CockroachDB.
Prerequisites
- CockroachDB cluster
1. Schema Configuration
In prisma/schema.prisma:
datasource db {
provider = "cockroachdb"
}
generator client {
provider = "prisma-client"
output = "../generated"
}
2. Config Configuration (v7)
In prisma.config.ts:
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
datasource: {
url: env('DATABASE_URL'),
},
})
Common Issues
Schema Introspection
Always use provider = "cockroachdb" to ensure correct type mapping during db pull.