prisma-database-setup
prisma/skills
關於如何搭配不同資料庫提供者(PostgreSQL、MySQL、SQLite、MongoDB 等)來設定 Prisma 的指南。 適用於建立新專案、更換資料庫或排除連線問題時。觸發條件為「configure postgres」、「connect to mysql」、「setup mongodb」、「sqlite setup」。
...展開全部關於「prisma-database-setup」
prisma-database-setup 是一種專注於特定工作流程的可重複使用 AI 技能。名稱:prisma-database-setup
此技能整合了操作說明、規範及特定任務的指引,讓操作人員能更一致地執行工作。描述:針對不同資料庫供應商(PostgreSQL、MySQL、SQLite、MongoDB 等)配置 Prisma 的指南。 適用於建立新專案、更換資料庫或排除連線問題時。觸發條件為「configure postgres」、「connect to mysql」、「setup mongodb」、「sqlite setup」。提供針對各種資料庫供應商配置 Prisma ORM 的完整指南。請在以下情況參考此技能:
實際上,此技能最適合需要可重複執行、且設定步驟較少、模糊性較低的使用者。 - 初始化新的 Prisma 專案 - 切換資料庫供應商 - 設定連線字串與環境變數 - 排除資料庫連線問題
常見問題
prisma-database-setup 能提供哪些協助?
prisma-database-setup 協助代理程式遵循原始文件中所述的聚焦工作流程,減少模糊性,並確保執行過程與預期任務保持一致。
何時應使用此技能?
當任務符合技能文件中所述的工作流程、領域或運作規則時,請使用此技能,特別是在需要一致執行時。
主要限制有哪些?
此技能受其來源指示的品質與範圍所限制。若基礎文件不完整,客服人員可能仍需額外的背景資訊或進行手動驗證。
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
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Provider Guides | CRITICAL | provider names |
| 2 | Prisma Postgres | HIGH | prisma-postgres |
| 3 | Client Setup | CRITICAL | prisma-client-setup |
System Prerequisites
- 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 | Mongo-specific workflow; do not apply SQL driver-adapter guidance |
| SQL Server | sqlserver | Microsoft ecosystem |
| CockroachDB | cockroachdb | Distributed SQL, Postgres-compatible |
| Prisma Postgres | postgresql | Managed serverless database |
Configuration Files
Your configuration shape depends on the provider and Prisma major version:
- All providers use
prisma/schema.prisma. - Prisma 7 SQL setups typically use
prisma.config.tsfor datasource URLs. - MongoDB projects should stay on Prisma 6.x, keep
url = env("DATABASE_URL")in the schema, and continue using the classic MongoDB setup.
Driver Adapters
The standard SQL workflow uses 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 (Node.js) | @prisma/adapter-pg | pg |
| Prisma Postgres (edge/serverless) | @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 |
MongoDB should not follow the Prisma 7 SQL adapter workflow. Use the latest Prisma 6.x release for MongoDB projects and do not install a SQL @prisma/adapter-* package for it.
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.
Install Prisma CLI and Prisma Client:
npm install prisma --save-devnpm install @prisma/client
Add a generator block (
prisma-clientrequires an explicit output path):generator client { provider = "prisma-client" output = "../generated"}
Generate Prisma Client:
npx prisma generate
For SQL providers, 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 })
Re-run
prisma generateafter 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
datasource db { provider = "mongodb" url = env("DATABASE_URL")}generator client { provider = "prisma-client-js"}
For MongoDB, stay on the latest Prisma 6.x line and keep the connection URL in schema.prisma. Do not move a MongoDB project to the Prisma 7 SQL adapter setup.
Rule Files
See individual rule files for detailed setup instructions:
references/postgresql.mdreferences/mysql.mdreferences/sqlite.mdreferences/mongodb.mdreferences/sqlserver.mdreferences/cockroachdb.mdreferences/prisma-postgres.mdreferences/prisma-client-setup.mdHow to Use
Choose the provider reference file for your database, then apply references/prisma-client-setup.md to complete client generation and adapter setup. For MongoDB, use references/mongodb.md instead of copying the SQL adapter examples or Prisma 7 config pattern.
安裝 prisma-database-setup
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/prisma/skills/blob/main/prisma-database-setup/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
