选项
首页首页 Skill 网页开发 prisma-database-setup

prisma-database-setup

prisma/skills prisma/skills

关于使用不同数据库提供商(PostgreSQL、MySQL、SQLite、MongoDB 等)配置 Prisma 的指南。 适用于新建项目、更换数据库或排查连接问题时。触发条件包括“配置 PostgreSQL”、“连接到 MySQL”、“设置 MongoDB”和“SQLite 设置”。

...展开全部
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