選項
首頁首頁 Skill 網頁開發 prisma-database-setup

prisma-database-setup

prisma/skills prisma/skills

關於如何搭配不同資料庫提供者(PostgreSQL、MySQL、SQLite、MongoDB 等)來設定 Prisma 的指南。 適用於建立新專案、更換資料庫或排除連線問題時。觸發條件為「configure postgres」、「connect to mysql」、「setup mongodb」、「sqlite setup」。

...展開全部
72
更新時間 2026-07-06

關於「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 協助代理程式遵循原始文件中所述的聚焦工作流程,減少模糊性,並確保執行過程與預期任務保持一致。

何時應使用此技能?

當任務符合技能文件中所述的工作流程、領域或運作規則時,請使用此技能,特別是在需要一致執行時。

主要限制有哪些?

此技能受其來源指示的品質與範圍所限制。若基礎文件不完整,客服人員可能仍需額外的背景資訊或進行手動驗證。

在 GitHub 上查看

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

PriorityCategoryImpactPrefix
1Provider GuidesCRITICALprovider names
2Prisma PostgresHIGHprisma-postgres
3Client SetupCRITICALprisma-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

DatabaseProvider StringNotes
PostgreSQLpostgresqlDefault, full feature support
MySQLmysqlWidespread support, some JSON diffs
SQLitesqliteLocal file-based, no enum/scalar lists
MongoDBmongodbMongo-specific workflow; do not apply SQL driver-adapter guidance
SQL ServersqlserverMicrosoft ecosystem
CockroachDBcockroachdbDistributed SQL, Postgres-compatible
Prisma PostgrespostgresqlManaged serverless database

Configuration Files

Your configuration shape depends on the provider and Prisma major version:

  1. All providers use prisma/schema.prisma.
  2. Prisma 7 SQL setups typically use prisma.config.ts for datasource URLs.
  3. 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.

DatabaseAdapterJS Driver
PostgreSQL@prisma/adapter-pgpg
CockroachDB@prisma/adapter-pgpg
Prisma Postgres (Node.js)@prisma/adapter-pgpg
Prisma Postgres (edge/serverless)@prisma/adapter-ppg@prisma/ppg
MySQL / MariaDB@prisma/adapter-mariadbmariadb
SQLite@prisma/adapter-better-sqlite3better-sqlite3
SQLite (Turso/LibSQL)@prisma/adapter-libsql@libsql/client
SQL Server@prisma/adapter-mssqlnode-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.

  1. Install Prisma CLI and Prisma Client:

    npm install prisma --save-devnpm install @prisma/client
  2. Add a generator block (prisma-client requires an explicit output path):

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

    npx prisma generate
  4. 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 })
  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

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.md

How 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

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/,Claude 會自動偵測並使用該技能
儲存庫 prisma/skills

相關技能

github-code-search
更新時間 2026-06-29
drizzle-orm
更新時間 2026-06-29
ui-test
更新時間 2026-09-29
clickhouse-io
更新時間 2026-06-29
OR