prisma-orm-setup
对比查看原文与翻译
🇺🇸
原文
英文🇨🇳
翻译
中文Prisma ORM setup
Prisma ORM 搭建
This skill owns ORM version selection for setup and connection work. Preserve the application's ORM version and intended database. A connection repair does not require a major upgrade.
New applications default to Prisma ORM 8. Detailed Prisma 8 configuration, queries, migrations, and runtime code belong to the versioned prisma-8 skill shipped with the ORM package.
本skill负责搭建和连接工作中的ORM版本选择。请保留应用的ORM版本和目标数据库。连接修复无需进行大版本升级。
新应用默认使用 Prisma ORM 8。Prisma 8的详细配置、查询、迁移和运行时代码由ORM包附带的版本化prisma-8 skill负责。
1. Detect the starting point
1. 确定起始状态
Read the package manifest, lockfile, Prisma configuration, schema, and application imports. Identify the ORM version, database provider, and runtime. The CLI version alone does not identify the application's version: a Prisma 8 CLI can coexist with a legacy client, so inspect , , and the schema and configuration.
@prisma/client@prisma/prisma7| Starting point | Path |
|---|---|
| Prisma 8 application | Step 4, without reinitializing |
| New application without a version choice | Step 3 |
| Prisma 6 or 7 application, or an explicit earlier major | Step 5 |
For a new application, check the selected Prisma 8 release's provider support and runtime requirements before installing. If the provider is unsupported, explain the limitation and offer an explicitly selected earlier version. Keep the requested database; do not silently fall back or invent a supported target.
Use an existing database when supplied. Load only when Prisma Postgres is needed and no connection has been selected yet; return here once connected.
prisma-postgres-setup读取包清单、锁文件、Prisma配置、schema和应用导入语句,识别ORM版本、数据库提供商和运行时环境。仅通过CLI版本无法确定应用的实际版本:Prisma 8 CLI可以与旧版客户端共存,因此需要检查、以及schema和配置文件。
@prisma/client@prisma/prisma7| 起始状态 | 操作路径 |
|---|---|
| Prisma 8 应用 | 直接进入第4步,无需重新初始化 |
| 未选择版本的新应用 | 进入第3步 |
| Prisma 6或7应用,或明确指定使用更早的主版本 | 第5步 |
对于新应用,安装前请检查所选Prisma 8版本的数据库提供商支持列表和运行时要求。如果目标数据库提供商不受支持,请说明限制,并提供明确指定的更早版本选项。保留用户请求的数据库;不要静默降级或虚构一个受支持的目标数据库。
如果用户提供了现有数据库,请直接使用。仅当需要使用Prisma Postgres且尚未选择连接方式时,才加载;连接完成后返回本流程。
prisma-postgres-setup2. Handle requested major upgrades separately
2. 单独处理用户请求的大版本升级
When the user requests a major upgrade, load a workflow that supports the source version and provider. For PostgreSQL 7-to-8, use the Prisma migration guide; for MongoDB 6-to-8, use prisma-mongodb-upgrade. Other providers need an explicitly supported migration path. covers 6 to 7; the package-owned upgrade reference covers updates within 8.
prisma-upgrade-v7prisma-8当用户请求大版本升级时,加载支持源版本和对应数据库提供商的工作流。对于PostgreSQL从7升级到8的场景,使用Prisma迁移指南;对于MongoDB从6升级到8的场景,使用prisma-mongodb-upgrade。其他数据库提供商需要有明确支持的迁移路径。负责6到7的升级;包自带的升级参考负责8版本内的更新。
prisma-upgrade-v7prisma-83. Bootstrap a new Prisma 8 application
3. 初始化新的Prisma 8应用
Check the selected release's runtime requirements and initialization guide. Resolve and pin a published Prisma CLI 8 release, including its prerelease suffix if needed; verify its version before initialization. Do not rely on a floating remaining version 8.
latestUse the project's package manager to run the installed CLI. For PostgreSQL and Prisma schema language authoring:
bash
prisma orm init --yes --target postgres --authoring pslUse the supported target for the selected provider. Preserve existing application files and connection configuration; do not let setup provision an unrelated database. Verify that the resolved ORM package is version 8 before proceeding.
4. Load the installed Prisma 8 guidance
4. 加载已安装的Prisma 8指南
Run the installed CLI through the project's package manager:
bash
prisma skills syncThen read the synced , for example , and follow its preconditions and selected references. Syncing alone does not load the instructions. If the package-owned guidance cannot be loaded, report the blocker. Continue with step 6.
prisma-8/SKILL.md.agents/skills/prisma-8/SKILL.md通过项目的包管理器运行已安装的CLI:
bash
prisma skills sync然后阅读同步后的(例如),并遵循其前置条件和选定的参考内容。仅执行同步操作不会加载相关说明。如果无法加载包自带的指南,请报告阻塞问题。之后继续执行第6步。
prisma-8/SKILL.md.agents/skills/prisma-8/SKILL.md5. Set up or repair an earlier version
5. 搭建或修复更早版本的Prisma
For a new setup that explicitly selects an earlier version, pin packages to that major and use its runtime requirements. Keep the CLI, client, and SQL adapter releases compatible. Existing dependencies need not change for a connection repair.
- Prisma 7 SQL: use the provider reference below and client setup.
- Prisma 6 MongoDB: use MongoDB setup. SQL driver adapters do not apply.
- Prisma 6 SQL: preserve its generator, schema URL, and client initialization. Use the provider's connection details below and the Prisma 6 documentation; do not copy the Prisma 7 configuration or adapter examples into it.
| Database | Reference |
|---|---|
| PostgreSQL | PostgreSQL |
| MySQL / MariaDB / PlanetScale | MySQL |
| SQLite / Turso | SQLite |
| Microsoft SQL Server / Azure SQL | SQL Server |
| CockroachDB | CockroachDB |
| MongoDB / Atlas on Prisma 6 | MongoDB |
| Prisma Postgres with Prisma 7 | Prisma Postgres |
The Prisma 7 SQL examples were verified with Prisma 7.10.0; the MongoDB examples with Prisma 6.19.3.
对于明确指定使用更早版本的新搭建场景,请将包锁定到对应主版本,并使用该版本的运行时要求。保持CLI、客户端和SQL适配器的版本兼容。如果只是连接修复,无需更改现有依赖。
- Prisma 7 SQL: 使用下方的数据库提供商参考和客户端搭建指南。
- Prisma 6 MongoDB: 使用MongoDB搭建指南。SQL驱动适配器不适用。
- Prisma 6 SQL: 保留其生成器、schema URL和客户端初始化配置。使用下方对应数据库提供商的连接详情和Prisma 6官方文档;不要将Prisma 7的配置或适配器示例复制到Prisma 6项目中。
| 数据库 | 参考文档 |
|---|---|
| PostgreSQL | PostgreSQL |
| MySQL / MariaDB / PlanetScale | MySQL |
| SQLite / Turso | SQLite |
| Microsoft SQL Server / Azure SQL | SQL Server |
| CockroachDB | CockroachDB |
| Prisma 6 适配的 MongoDB / Atlas | MongoDB |
| 搭配 Prisma 7 使用的 Prisma Postgres | Prisma Postgres |
Prisma 7 SQL示例已在Prisma 7.10.0版本上验证;MongoDB示例已在Prisma 6.19.3版本上验证。
6. Connect and verify
6. 连接并验证
The CLI and the application can load different environment files. Load the intended environment for each without printing secrets, and keep credentials in ignored environment files or the host's secret configuration. For SQL adapters, make the adapter's runtime options address the same database as the CLI connection URL.
For an existing app, preserve schema, migrations, and generator configuration unless the requested work requires changes. Diagnose the connection before running schema-changing commands.
Run the project's relevant checks and a read-only query through the application's client against the intended database. Report the ORM version, the loaded skill version where applicable, and the query result. Package installation or a successful skill sync alone is not a completed setup.
prisma-8CLI和应用可能加载不同的环境变量文件。请为两者加载对应的目标环境,不要打印密钥信息,将凭证保存在被忽略的环境变量文件或主机的密钥配置中。对于SQL适配器,请确保适配器的运行时选项指向的数据库与CLI连接URL指向的数据库一致。
对于现有应用,除非请求的工作需要更改,否则请保留schema、迁移文件和生成器配置。在运行会修改schema的命令前,先排查连接问题。
运行项目相关的检查,并通过应用的客户端对目标数据库执行一次只读查询。报告ORM版本、适用情况下已加载的 skill版本,以及查询结果。仅完成包安装或skill同步并不代表搭建完成。
prisma-8