← 返回列表
全部 Skill›数据库 Databases›prisma-8

prisma-8

作者 @prisma · 语言 en
Use when working in a project that depends on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo (Prisma 8, formerly Prisma Next): editing contract.prisma or a contract.ts builder, running `prisma contract emit`, planning or applying migrations, editing migration.ts, writing db.orm / db.sql / db.query queries, wiring db.ts or middleware, integrating a build tool, using the Supabase extension or RLS, or reading a dotted error code such as MIGRATION.HASH_MISMATCH. Use when the user asks "what is Prisma 8", "where do I start", or compares it to another ORM. Use when the user asks to upgrade or bump Prisma 8 in an app or an extension package. Use when you see @prisma/orm-* imports, prisma.config.ts with definePrismaConfig, or contract.json / contract.d.ts. Do not use for Prisma ORM 7 or earlier (schema.prisma + @prisma/client).
数据库 DatabasesSQL 数据库通用敏感路径待翻译
存储库
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
47,694
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Prisma 8 (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.

Pre-conditions

Check these before acting on anything below. Halt on the first one that fails and tell the user what is missing. Pre-conditions 1 and 3 describe an application that is already set up. Check only pre-condition 2 in a package that builds a target or is a Prisma extension, and when setting up a new project, which creates what 1 and 3 check.

  1. The project is on Prisma 8. prisma.config.ts exports definePrismaConfig({ orm: ... }), and package.json depends on a target package: @prisma/orm-postgres, @prisma/orm-mongo, @prisma/orm-sqlite, @prisma/orm-mysql, @prisma/orm-mariadb, or another package that prisma.config.ts imports defineConfig from. A project with schema.prisma and @prisma/client is Prisma 7 or earlier; this skill does not apply to it, and its instructions will break such a project.
  2. The skill matches the installed version. Compare metadata.library_version in this file's frontmatter with the installed @prisma/orm-* version in package.json. If they differ, run prisma skills sync and re-read this file before continuing. If no @prisma/orm-* package is installed, as in a project not set up yet, this check passes.
  3. The contract artefacts exist. contract.json and contract.d.ts sit next to the contract source named by prisma.config.ts. If they are missing or older than the source, run prisma contract emit first; every query and migration instruction below assumes current artefacts.

Import paths in the references. The reference files name the published packages an application installs: @prisma/orm-<target>/<subpath> (@prisma/orm-postgres/runtime, @prisma/orm-mongo/config, @prisma/orm-sqlite/runtime) and @prisma/orm-extension-<name>/<subpath> (@prisma/orm-extension-pgvector/control). Some older per-transition instructions under upgrading/ name a package by the Prisma repository's workspace name, which is not published; find the @prisma/orm-* entry that carries the same module before writing it into user code. The metadata.library_version in this file's frontmatter is the version it was published with; if it does not match the project's installed Prisma packages, run prisma skills sync and re-read.

Never reset or drop a database

Never reset or drop a database to fix a migration, marker or contract problem, and never propose it. A database can always be moved to the contract you want. When its migration history does not need to be kept (a local, development, staging or preview database), reconcile it with prisma db update. When it changes only through migrations, as production should, author the migrations that bring it there. The database's change policy, recorded in its marker, says which it is, and db update refuses one that permits only migrations; never edit a ref's policies or pass --permit-policy-change to get past that. A deploy that says there is no migration path, or MIGRATION.MARKER_MISMATCH, is covered in references/migrations.md § *A database whose marker is not in the migration graph*.

Prisma 8 is a contract-first data layer. This skill routes every Prisma 8 task to the right reference file — open the reference before writing code; do not answer from this file alone.

The canonical model (one paragraph)

You author a data contract (a contract.prisma file, or a TypeScript builder). The framework emits machine-readable artifacts (contract.json, contract.d.ts) and gives you two runtime surfaces on SQL targets: a typed SQL query builder (db.sql.<ns>.<table>) and a typed ORM client (db.orm.<ns>.<Model>). On MongoDB targets only the ORM lane exists, and its keys are collection storage names (db.orm.users) rather than PSL model names — references/queries.md § *MongoDB ORM addressing* covers the rule. Migrations are planned from the contract diff; you review them, optionally edit the migration.ts for data transforms, and apply.

Three steps the user does:

  1. Edit your data contract. (references/contract.md)
  2. The system plans the migrations for you. (references/migrations.md)
  3. If you need a data migration, you write a dataTransform in migration.ts and execute it. Inserts, updates and deletes never go in a rawSql step. (references/migrations.md)

Everything else — queries, runtime wiring, build integration, debugging, feedback — sits on top of those three.

One cross-cutting migration fact: migration plan does not chain from the ne

评论
Pprisma
prisma
prisma/orm
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@prisma
所属大类数据库 Databases / SQL 数据库
国内可用性通用
最近源活动—
风险提示敏感路径
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。