prisma-8
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrisma Next (Prisma 8)
Prisma Next(Prisma 8)
Edit your data contract. Prisma handles the rest.
Prisma 8 moves fast, and your training data about it is very likely outdated. This skill ships inside the installed Prisma packages, so it describes the exact version this project has — treat it and its reference files as the source of truth, over anything you remember about Prisma. The in this file's frontmatter is the version it was published with; if it does not match the project's installed Prisma packages, run and re-read.
metadata.library_versionprisma skills syncPrisma Next is a contract-first data layer. This skill routes every Prisma Next task to the right reference file — open the reference before writing code; do not answer from this file alone.
编辑你的数据契约。其余工作由Prisma处理。
Prisma 8更新迭代很快,你所了解的相关知识很可能已经过时。此技能随已安装的Prisma包一同发布,因此它描述的是当前项目所安装的精确版本——请将本指南及其参考文件视为权威来源,而非你记忆中关于Prisma的内容。本文件前置元数据中的是其发布时的版本;如果它与项目中已安装的Prisma包版本不匹配,请运行后重新阅读。
metadata.library_versionprisma skills syncPrisma Next是一款契约优先的数据层工具。此技能会将每一项Prisma Next任务引导至对应的参考文件——在编写代码前请先打开参考文件;不要仅依靠本文件作答。
The canonical model (one paragraph)
规范模型(概述)
You author a data contract (a file, or a TypeScript builder). The framework emits machine-readable artifacts (, ) and gives you two runtime surfaces on SQL targets: a typed SQL query builder () and a typed ORM client (). On MongoDB targets only the ORM lane exists, and its keys are collection storage names () rather than PSL model names — § MongoDB ORM addressing covers the rule. Migrations are planned from the contract diff; you review them, optionally edit the for data transforms, and apply.
contract.prismacontract.jsoncontract.d.tsdb.sql.<ns>.<table>db.orm.<ns>.<Model>db.orm.usersreferences/queries.mdmigration.tsThree steps the user does:
- Edit your data contract. ()
references/contract.md - The system plans the migrations for you. ()
references/migrations.md - If you need data migrations, you edit and execute it. (
migration.ts)references/migrations.md
Everything else — queries, runtime wiring, build integration, debugging, feedback — sits on top of those three.
One cross-cutting migration fact: does not chain from the newest migration on disk. Its origin is , else the ref, else an empty database — so a project with no ref keeps planning from scratch. Over existing migrations the CLI refuses that () instead of writing a full-create package; choose the exit that matches your intent rather than reflexively passing . § The trap explains which to choose.
migration plan--fromdbMIGRATION.PLAN_ORIGIN_UNKNOWN--from @emptyreferences/migration-model.md你需要编写一份数据契约(一个文件,或使用TypeScript构建器)。框架会生成机器可读的产物(、),并为SQL目标提供两个运行时接口:一个类型化SQL查询构建器()和一个类型化ORM客户端()。对于MongoDB目标,仅提供ORM接口,且其键为集合存储名称()而非PSL模型名称——详情请参考中的MongoDB ORM寻址章节。迁移操作会根据契约差异进行规划;你可以审查这些迁移,选择性编辑以进行数据转换,然后执行迁移。
contract.prismacontract.jsoncontract.d.tsdb.sql.<ns>.<table>db.orm.<ns>.<Model>db.orm.usersreferences/queries.mdmigration.ts用户需要完成的三个步骤:
- 编辑你的数据契约。()
references/contract.md - 系统会为你规划迁移方案。()
references/migrations.md - 如果需要数据迁移,编辑并执行。(
migration.ts)references/migrations.md
其他所有操作——查询、运行时配置、构建集成、调试、反馈——都建立在这三个步骤之上。
一个关于迁移的重要跨领域事实:不会从磁盘上最新的迁移文件开始链式生成。它的起点是参数指定的版本,否则是引用,再否则是空数据库——因此没有引用的项目会始终从头开始规划。对于已存在迁移文件的项目,CLI会拒绝这种行为(错误码),而非生成完整的创建包;请选择符合你意图的退出方式,而非习惯性地传递参数。中的陷阱章节解释了该如何选择。
migration plan--fromdbMIGRATION.PLAN_ORIGIN_UNKNOWN--from @emptyreferences/migration-model.mdRouting table
路由表
Open the reference whose triggers match the task. If more than one matches, open each — they are written to compose.
| Task | Reference | Triggers |
|---|---|---|
| Adopt / set up / first steps | | new project, existing database, "what can I do with Prisma Next", "where do I start", "just ran createprisma", |
| Edit the data contract | | schema, models, fields, attributes, relations, indexes, enums, value objects (composite types), type aliases, namespaces (Postgres schemas), cross-contract foreign keys (cross-space FK), polymorphic types ( |
| Author migrations | | |
| Migration graph, refs, plan origin | | migration graph, refs, |
| Review migrations on deploy | | "what migrations are going to run", "what runs on deploy / merge", merge conflict, diamond convergence, concurrent migrations, migration status, ref management for CI, staging / production environment refs, |
| Write queries | | query, where, select, project, orderBy, limit, offset, take, skip, include, lookup, first, all, count, aggregate, groupBy, create, update, delete, upsert, returning, transaction, |
| Wire the runtime | | |
| Build-tool integration | | Vite plugin ( |
| Supabase | | |
| Debug an error | | any structured error envelope (code, domain, severity, why, fix, meta), emit failed, query won't typecheck, query crashed, migration won't apply, |
| Upgrade Prisma in an app | | "upgrade Prisma", "upgrade Prisma Next", "bump Prisma Next", "move to Prisma Next X.Y", |
| Upgrade Prisma in an extension | | the same request in a package that is a Prisma extension ( |
| File feedback / ask the team | | bug report, file an issue, feature request, missing feature, capability gap, "this is broken", surprising behaviour, Q&A / design discussion, ask the Prisma team, Prisma Discord (pris.ly/discord), extension-author questions |
打开与任务触发条件匹配的参考文件。如果有多个匹配项,请依次打开——这些文件的内容是互补的。
| 任务 | 参考文件 | 触发条件 |
|---|---|---|
| 采用/设置/初始步骤 | | 新项目、现有数据库、“我可以用Prisma Next做什么”、“我从哪里开始”、“刚运行createprisma”、 |
| 编辑数据契约 | | schema、模型、字段、属性、关联关系、索引、枚举、值对象(复合类型)、类型别名、命名空间(Postgres模式)、跨契约外键(跨空间FK)、多态类型( |
| 编写迁移脚本 | | |
| 迁移图、引用、规划起点 | | 迁移图、引用、 |
| 部署时审查迁移 | | “将要执行哪些迁移”、“部署/合并时会运行什么”、合并冲突、菱形收敛、并发迁移、迁移状态、CI环境的引用管理、预发布/生产环境引用、 |
| 编写查询语句 | | 查询、where、select、project、orderBy、limit、offset、take、skip、include、lookup、first、all、count、aggregate、groupBy、create、update、delete、upsert、returning、事务、 |
| 配置运行时 | | |
| 构建工具集成 | | Vite插件( |
| Supabase | | |
| 调试错误 | | 任何结构化错误包(代码、领域、严重程度、原因、修复方案、元数据)、生成失败、查询无法通过类型检查、查询崩溃、迁移无法执行、 |
| 在应用中升级Prisma | | “升级Prisma”、“升级Prisma Next”、“更新Prisma Next版本”、“迁移至Prisma Next X.Y”、应用中 |
| 在扩展包中升级Prisma | | 在Prisma扩展包(依赖 |
| 提交反馈/咨询团队 | | 错误报告、提交Issue、功能请求、功能缺失、功能缺口、“这部分坏了”、意外行为、问答/设计讨论、咨询Prisma团队、Prisma Discord(pris.ly/discord)、扩展包开发者问题 |
Routing rules
路由规则
If the task clearly matches a row, open that reference directly without asking.
For a vague prompt, ask one disambiguating question. Pick from:
- "Are you new to Prisma Next and asking what you can do with it, or where to start?" → (first-touch orientation path).
references/quickstart.md - "Do you want to set up a new Prisma Next project, or wire it into an existing database?" → .
references/quickstart.md - "Do you want to edit your data contract (add a model / field / relation), or work with the database (migrations, queries)?" → vs the others.
references/contract.md - "Is this about authoring a migration, or about reviewing what's going to run on deploy?" → vs
references/migrations.md. If it's about where a plan starts, refs, or an unexpected from-scratch plan →references/migration-review.md.references/migration-model.md - "Is this about wiring Prisma Next into your build tool (Vite / Next.js / …), or about wiring and middleware at runtime?" →
db.tsvsreferences/build.md.references/runtime.md - "What error or symptom are you seeing?" → .
references/debug.md - "Do you want to report this as a bug to the Prisma Next team, or is this a feature request?" → .
references/feedback.md - "Is the project you want to upgrade an application, or a Prisma extension package?" → vs
references/upgrade-app.md.references/upgrade-extension.md
If you still can't tell which reference applies, ask the user what they want to do. Do not guess.
如果任务明确匹配某一行,请直接打开对应的参考文件,无需询问。
对于模糊的请求,请提出一个明确的问题。可选问题如下:
- “你是刚接触Prisma Next,想了解它的功能或入门方法吗?” → (首次接触的引导路径)。
references/quickstart.md - “你想要搭建一个新的Prisma Next项目,还是将其接入现有的数据库?” → 。
references/quickstart.md - “你想要编辑数据契约(添加模型/字段/关联关系),还是进行数据库相关操作(迁移、查询)?” → 或其他对应文件。
references/contract.md - “这是关于编写迁移脚本,还是关于审查部署时将要执行的内容?” → 对比
references/migrations.md。如果是关于规划起点、引用或意外的从头规划问题 →references/migration-review.md。references/migration-model.md - “这是关于将Prisma Next接入构建工具(Vite / Next.js / …),还是关于配置和运行时中间件?” →
db.ts对比references/build.md。references/runtime.md - “你遇到了什么错误或症状?” → 。
references/debug.md - “你想要向Prisma Next团队提交错误报告,还是提出功能请求?” → 。
references/feedback.md - “你想要升级的项目是应用,还是Prisma扩展包?” → 对比
references/upgrade-app.md。references/upgrade-extension.md
如果仍然无法确定适用的参考文件,请询问用户具体想要做什么。不要猜测。
Checklist
检查清单
- If the task matches a routing-table row, open that reference before writing code.
- If the prompt is vague, ask one disambiguating question.
- Do not attempt to answer from this file alone — the references carry the verified tool surface.
- If the user describes a missing feature or a misbehaviour they want fixed, open .
references/feedback.md
- 如果任务匹配路由表中的某一行,请在编写代码前打开对应的参考文件。
- 如果请求模糊,请提出一个明确的问题。
- 不要仅依靠本文件作答——参考文件包含经过验证的工具接口信息。
- 如果用户描述了缺失的功能或需要修复的异常行为,请打开。
references/feedback.md