prisma-database-setup

prisma-database-setup

Guides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing databases, or troubleshooting connection issues. Triggers on "configure postgres", "connect to mysql", "setup mongodb", "sqlite setup".

6Star
0Fork
更新于 2/5/2026
SKILL.md
readonly只读
name
prisma-database-setup
description

Guides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing databases, or troubleshooting connection issues. Triggers on "configure postgres", "connect to mysql", "setup mongodb", "sqlite setup".

version
"1.0.0"

Prisma Database Setup

Comprehensive guides for configuring Prisma ORM with various database providers.

When to Apply

Reference this skill when:

  • Initializing a new Prisma project
  • Switching database providers
  • Configuring connection strings and environment variables
  • Troubleshooting database connection issues
  • Setting up database-specific features
  • Generating and instantiating Prisma Client

System Prerequisites (Prisma ORM 7)

  • Node.js 20.19.0+
  • TypeScript 5.4.0+

Bun Runtime

If you're using Bun, run Prisma CLI commands with bunx --bun prisma ... so Prisma uses the Bun runtime instead of falling back to Node.js.

Supported Databases

Database Provider String Notes
PostgreSQL postgresql Default, full feature support
MySQL mysql Widespread support, some JSON diffs
SQLite sqlite Local file-based, no enum/scalar lists
MongoDB mongodb NOT SUPPORTED IN v7 (Use v6)
SQL Server sqlserver Microsoft ecosystem
CockroachDB cockroachdb Distributed SQL, Postgres-compatible
Prisma Postgres postgresql Managed serverless database

Configuration Files

Prisma v7 uses two main files for configuration:

  1. prisma/schema.prisma: Defines the datasource block.
  2. prisma.config.ts: Configures the connection URL (replaces env loading in schema).

Driver Adapters (Prisma ORM 7)

Prisma ORM 7 uses the query compiler by default, which requires a driver adapter. Choose the adapter and driver for your database and pass the adapter to PrismaClient.

Database Adapter JS Driver
PostgreSQL @prisma/adapter-pg pg
CockroachDB @prisma/adapter-pg pg
Prisma Postgres @prisma/adapter-ppg @prisma/ppg
MySQL / MariaDB @prisma/adapter-mariadb mariadb
SQLite @prisma/adapter-better-sqlite3 better-sqlite3
SQLite (Turso/LibSQL) @prisma/adapter-libsql @libsql/client
SQL Server @prisma/adapter-mssql node-mssql

Example (PostgreSQL):

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 })

Prisma Client Setup (Required)

Prisma Client must be installed and generated for any database.

  1. Install Prisma CLI and Prisma Client:

    npm install prisma --save-dev
    npm install @prisma/client
    
  2. Add a generator block (output is required in Prisma v7):

    generator client {
      provider = "prisma-client"
      output   = "../generated"
    }
    
  3. Generate Prisma Client:

    npx prisma generate
    
  4. Instantiate Prisma Client with the database-specific driver adapter:

    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 })
    
  5. Re-run prisma generate after every schema change.

Quick Reference

PostgreSQL

datasource db {
  provider = "postgresql"
}

generator client {
  provider = "prisma-client"
  output   = "../generated"
}

MySQL

datasource db {
  provider = "mysql"
}

generator client {
  provider = "prisma-client"
  output   = "../generated"
}

SQLite

datasource db {
  provider = "sqlite"
}

generator client {
  provider = "prisma-client"
  output   = "../generated"
}

MongoDB (Prisma v6 only)

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

Rule Files

See individual rule files for detailed setup instructions:

rules/postgresql.md
rules/mysql.md
rules/sqlite.md
rules/mongodb.md
rules/sqlserver.md
rules/cockroachdb.md
rules/prisma-postgres.md
rules/prisma-client-setup.md

You Might Also Like

Related Skills

verify

verify

243K

Use when you want to validate changes before committing, or when you need to check all React contribution requirements.

facebook avatarfacebook
获取
test

test

243K

Use when you need to run tests for React core. Supports source, www, stable, and experimental channels.

facebook avatarfacebook
获取

Use when feature flag tests fail, flags need updating, understanding @gate pragmas, debugging channel-specific test failures, or adding new flags to React.

facebook avatarfacebook
获取

Use when adding new error messages to React, or seeing "unknown error code" warnings.

facebook avatarfacebook
获取
flow

flow

243K

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

facebook avatarfacebook
获取
flags

flags

243K

Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.

facebook avatarfacebook
获取