[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EQM2TH50FXV1876334WAVP":3,"skill-same:01M7EQM2TH50FXV1876334WAVP":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M7EQM2TH50FXV1876334WAVP","prisma-orm",null,"Use when modeling data or writing type-safe queries with Prisma ORM in TypeScript — `schema.prisma`, `prisma.config.ts`, the generated Prisma Client, and Prisma Migrate, including the v6 to v7 upgrade. NOT schema-as-TS with a SQL builder (that is `drizzle-orm`), NOT ORM-agnostic zero-downtime migration (that is `db-migrations`), NOT Postgres engine tuning (that is `postgresdb`).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fprisma-orm\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: prisma-orm\ndescription: \"Use when modeling data or writing type-safe queries with Prisma ORM in TypeScript — `schema.prisma`, `prisma.config.ts`, the generated Prisma Client, and Prisma Migrate, including the v6 to v7 upgrade. NOT schema-as-TS with a SQL builder (that is `drizzle-orm`), NOT ORM-agnostic zero-downtime migration (that is `db-migrations`), NOT Postgres engine tuning (that is `postgresdb`).\"\ntags:\n  - prisma\n  - prisma-orm\n  - typescript-orm\n  - prisma-migrate\n  - schema\n  - migrations\n  - orm\nrecommends:\n  - drizzle-orm\n  - db-migrations\n  - postgresdb\n  - neon\n  - planetscale\n  - supabase\n  - sqlite-turso\n  - typescript\n  - sql\norigin: risco\n---\n\n# Prisma ORM (v7)\n\nYou declare a data model in `schema.prisma`, generate a type-safe client, and query it\nwithout the foot-guns: N+1, over-fetch, unbounded reads. This skill is **Prisma 7-native**.\nIf you are writing `prisma-client-js`, `binaryTargets`, or `new PrismaClient()` with no\nadapter, you are writing v6 — stop and read the upgrade notes.\n\n## Decide first\n\nPrisma is a **schema DSL (`schema.prisma`) + a generated type-safe client + Prisma Migrate**.\nThe rival, Drizzle, is **schema-as-TypeScript with a SQL builder and no codegen** — if the\nask says `pgTable`, `drizzle-kit`, or `drizzle.config.ts`, that is `..\u002Fdrizzle-orm\u002FSKILL.md`,\nnot here.\n\nPrisma 7 has four non-negotiables. Get these wrong and nothing runs:\n\n1. **Generator is `provider = \"prisma-client\"` and `output` is REQUIRED.** The client is no\n   longer emitted into `node_modules` — you import it from your generated path. The legacy\n   `prisma-client-js` generator is gone.\n2. **A driver adapter is REQUIRED on the constructor.** `new PrismaClient({ adapter })`. Omit\n   it and you get `requires either adapter or accelerateUrl` at runtime.\n3. **Connection config lives in `prisma.config.ts`, not the datasource block.** `url`,\n   `directUrl`, `shadowDatabaseUrl` in `schema.prisma` are deprecated in v7.\n4. **Rust-free by default.** The query engine is TypeScript now — no native binaries, ~3x\n   faster queries, ~90% smaller bundles. `binaryTargets` no longer exists.\n\nVersion note: stable is the **7.x** line — latest stable is 7.7.0 (2026-04-07) per the\n[Prisma changelog](https:\u002F\u002Fwww.prisma.io\u002Fchangelog) (accessed 2026-06-02); pin `>=7.7`.\n\"Prisma Next\" — the future fully-TS foundation, first announced 2026-03-04 in\n[The Next Evolution of Prisma ORM](https:\u002F\u002Fwww.prisma.io\u002Fblog\u002Fthe-next-evolution-of-prisma-orm)\n— reached **Early Access in May 2026** per the\n[Prisma Next Roadmap](https:\u002F\u002Fwww.prisma.io\u002Fblog\u002Fprisma-next-roadmap) (2026-03-20, accessed\n2026-06-02). Early Access is forward-looking only and **not** the install default; for\nproduction work stay on stable 7.x.\n\n## Install & config\n\nInstall the CLI, the client, and the adapter for your database. One adapter per DB.\n\n```bash\n# Postgres\nnpm i -D prisma\nnpm i @prisma\u002Fclient @prisma\u002Fadapter-pg\n# others: @prisma\u002Fadapter-better-sqlite3, -libsql, -mariadb, -mssql, -d1\n```\n\nMinimal `schema.prisma` — note the generator shape and the **no-url datasource**:\n\n```prisma\ngenerator client {\n  provider = \"prisma-client\"\n  output   = \"..\u002Fsrc\u002Fgenerated\u002Fprisma\" \u002F\u002F REQUIRED in v7\n}\n\ndatasource db {\n  provider = \"postgresql\" \u002F\u002F url moved to prisma.config.ts\n}\n```\n\n`prisma.config.ts` holds the connection (replaces `url` in the datasource):\n\n```ts\nimport \"dotenv\u002Fconfig\";\nimport { defineConfig } from \"prisma\u002Fconfig\";\n\nexport default defineConfig({\n  schema: \"prisma\u002Fschema.prisma\",\n  migrations: { seed: \"tsx prisma\u002Fseed.ts\" },\n  datasource: { url: process.env.DATABASE_URL! },\n});\n```\n\n`package.json` scripts:\n\n```json\n{\n  \"scripts\": {\n    \"db:generate\": \"prisma generate\",\n    \"db:migrate\": \"prisma migrate dev\",\n    \"db:deploy\": \"prisma migrate deploy\",\n    \"db:seed\": \"prisma db seed\"\n  }\n}\n```\n\n## Model the schema\n\n`schema.prisma` is the single source of truth. Every relation needs an explicit FK field and\nan index on that FK column — Prisma does **not** index foreign keys for you, and a join on an\nunindexed column is a sequential scan.\n\n```prisma\nmodel User {\n  id        String   @id @default(cuid())\n  email     String   @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  role      Role     @default(MEMBER)\n  posts     Post[]\n}\n\nmodel Post {\n  id        String   @id @default(cuid())\n  title     String\n  body      String   @db.Text \u002F\u002F native type\n  published Boolean  @default(false)\n  author    User     @relation(fields: [authorId], references: [id])\n  authorId  String\n  createdAt DateTime @default(now())\n\n  @@index([authorId])            \u002F\u002F index the FK you join\u002Ffilter on\n  @@unique([authorId, title])    \u002F\u002F composite uniqueness\n}\n\nenum Role {\n  ADMIN\n  MEMBER\n}\n```\n\n```prisma\n\u002F\u002F Bad: relation with no index on the FK — every join scans the table\nmodel Post {\n  author   User   @relation(fields: [authorId], references: [id])\n  authorId String\n}\n\u002F\u002F Good: add @@index([authorId]) — see the model above.\n```\n\n## Instantiate the client\n\n**One `PrismaClient` per process.** A new client per request opens a fresh connection pool\neach time and exhausts the database. In dev, pin it to `globalThis` so HMR reuses one instance.\n\n```ts\nimport { PrismaClient } from \"..\u002Fgenerated\u002Fprisma\u002Fclient\";\nimport { PrismaPg } from \"@prisma\u002Fadapter-pg\";\n\nconst adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });\n\nconst globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };\nexport const prisma =\n  globalForPrisma.prisma ??\n  new PrismaClient({ adapter, log: [\"query\"] }); \u002F\u002F log surfaces emitted SQL\n\nif (process.env.NODE_ENV !== \"production\") globalForPrisma.prisma = prisma;\n```\n\n```ts\n\u002F\u002F Bad: no adapter → throws \"requires either adapter or accelerateUrl\"\nexport const prisma = new PrismaClient();\n\u002F\u002F Bad: per-request instance → connection-pool exhaustion\napp.get(\"\u002Fu\", () => new PrismaClient({ adapter }).user.findMany());\n```\n\n## Query safely\n\nThree rules cover most query bugs:\n\n- **Prefer `select` over `include`.** `select` returns only the named fields; `include` adds a\n  relation but otherwise returns **all** scalar fields (over-fetch). Never put `select` and\n  `include` at the same level — Prisma rejects it.\n- **Always pass `take` to `findMany`.** It is unbounded by default and will happily stream the\n  whole table.\n- **Never query inside a loop.** Batch with `where: { id: { in: ids } }`.\n\n```ts\n\u002F\u002F Good: shape the row, bound the read\nconst users = await prisma.user.findMany({\n  take: 20,\n  where: { role: \"MEMBER\" },\n  select: { id: true, email: true, posts: { select: { title: true } } },\n});\n```\n\n```ts\n\u002F\u002F Bad: N queries in a loop\nfor (const id of ids) {\n  await prisma.user.findUnique({ where: { id } });\n}\n\u002F\u002F Good: one query\nconst users = await prisma.user.findMany({ where: { id: { in: ids } } });\n```\n\nPagination — pick by table size:\n\n| Need | Use | Why |\n| --- | --- | --- |\n| Small\u002Fmedium set, jump to page N | `skip` + `take` (offset) | Simple; `skip` gets slow on huge offsets |\n| Large set, infinite scroll, stable | `cursor` + `take` | Seeks by indexed id, constant cost |\n\nWrites: `upsert` for create-or-update; `createMany({ data, skipDuplicates: true })` for bulk.\n\nTransactions — pick by dependency:\n\n| Situation | Form |\n| --- | --- |\n| Independent writes that must all commit | `prisma.$transaction([opA, opB])` (array) |\n| Read, branch on the result, then write | `prisma.$transaction(async (tx) => { … })` (interactive) |\n\nLean on generated types instead of hand-writing shapes: `Prisma.UserGetPayload\u003C…>` and\n`Prisma.validator` keep a query and its type in sync. See\n`references\u002Fqueries-and-performance.md` for the full cookbook.\n\n## Performance: kill N+1 and over-fetch\n\n`relationLoadStrategy` decides how relations load:\n\n- `\"join\"` (default) — one query: a LATERAL JOIN with JSON aggregation on Postgres (correlated\n  subqueries on MySQL). This is the N+1 killer. The top-level choice cascades to nested loads.\n- `\"query\"` — one query per relation, joined in the app. Sometimes wins when a join fans out\n  rows badly.\n\n```ts\nconst feed = await prisma.user.findMany({\n  relationLoadStrategy: \"join\",\n  take: 20,\n  select: { id: true, email: true, posts: { select: { id: true, title: true } } },\n});\n```\n\nThen: `select` only the fields you render, and `@@index` the columns you filter and order on.\nTo see what Prisma actually emits, set `log: [\"query\"]` on the client and read the SQL. For\nthe deep perf checklist (N+1 detection, index selection, reading the plan) see\n`references\u002Fqueries-and-performance.md`. For `EXPLAIN ANALYZE`, index theory, and pool sizing\n— that is the database engine's job: `..\u002Fpostgresdb\u002FSKILL.md`.\n\n## Raw SQL safely\n\nUse raw SQL **only** through the tagged-template form — it parameterizes. The `*Unsafe`\nvariants concatenate strings and open SQL injection.\n\n```ts\n\u002F\u002F Good: parameterized tagged template\nconst rows = await prisma.$queryRaw`SELECT id FROM \"User\" WHERE email = ${email}`;\n\n\u002F\u002F Bad: interpolated string into the Unsafe API → SQL injection\nconst rows = await prisma.$queryRawUnsafe(`SELECT id FROM \"User\" WHERE email = '${email}'`);\n```\n\nCompose fragments with `Prisma.sql` \u002F `Prisma.join`. For fully type-checked results, write\n`.sql` files and use `$queryRawTyped`. Safety matrix in\n`references\u002Fqueries-and-performance.md`.\n\n## Migrations\n\nPick the command by environment — this is the most common mix-up:\n\n| Command | Use where | Does |\n| --- | --- | --- |\n| `prisma migrate dev` | **development only** | Creates a migration, applies it, regenerates the client; uses a shadow DB |\n| `prisma migrate deploy` | **CI \u002F production** | Applies pending migrations only — never generates, never resets |\n| `prisma db push` | prototyping \u002F spikes | Syncs schema to the DB with **no** migration file |\n\nRules with teeth:\n\n- **Never run `migrate dev` against production.** It can reset the database.\n- **Never edit a migration that has already been applied.** Create a new one.\n- A shadow DB lets `migrate dev` detect drift; it must be a separate, disposable database.\n- On drift or a failed migration, use `prisma migrate resolve --applied|--rolled-back`.\n- Seed via the `seed` entry in `prisma.config.ts` and `prisma db seed`.\n\nFailed-migration recovery, baselining an existing database, and the full Prisma 6 to 7\nupgrade are in `references\u002Fmigrations-and-v7-upgrade.md`. For ORM-independent evolution\nstrategy (expand\u002Fcontract, dual-write, zero-downtime backfills) that is\n`..\u002Fdb-migrations\u002FSKILL.md`.\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n| --- | --- | --- |\n| `new PrismaClient()` with no adapter | v7 throws `requires either adapter or accelerateUrl` | Pass a driver adapter |\n| New `PrismaClient` per request | Pool exhaustion, dropped connections | One instance per process; `globalThis` in dev |\n| `prisma-client-js` generator | Legacy v6 generator, removed in v7 | `provider = \"prisma-client\"` + `output` |\n| `binaryTargets` in the generator | Rust-era artifact; v7 is Rust-free | Delete it |\n| Unbounded `findMany()` | Streams the whole table | Always pass `take` (and `cursor` for paging) |\n| Fat `include` everywhere | Over-fetches every scalar | `select` only the rendered fields |\n| Query inside a `for` loop | N+1 round trips | Batch `where: { id: { in: ids } }` or `relationLoadStrategy: \"join\"` |\n| `$queryRawUnsafe(\\`…${x}…\\`)` | SQL injection | Tagged `$queryRaw\\`…${x}\\`` |\n| `migrate dev` in CI\u002Fprod | Can reset the production DB | `migrate deploy` |\n| Editing an applied migration | Drift, broken history | New migration; `migrate resolve` for drift |\n| FK with no `@@index` | Joins do sequential scans | `@@index([fkColumn])` |\n\n## Verify\n\nRun `scripts\u002Fverify.sh \u003Cpath>` to statically check emitted artifacts: it confirms the\n`prisma-client` generator + `output`, an adapter on the constructor, and flags\n`$queryRawUnsafe` injection, `binaryTargets`, unbounded `findMany`, and wrong-ORM\ncontamination. Read-only; no database connection.\n","# Prisma ORM (v7)\n\nYou declare a data model in `schema.prisma`, generate a type-safe client, and query it\nwithout the foot-guns: N+1, over-fetch, unbounded reads. This skill is **Prisma 7-native**.\nIf you are writing `prisma-client-js`, `binaryTargets`, or `new PrismaClient()` with no\nadapter, you are writing v6 — stop and read the upgrade notes.\n\n## Decide first\n\nPrisma is a **schema DSL (`schema.prisma`) + a generated type-safe client + Prisma Migrate**.\nThe rival, Drizzle, is **schema-as-TypeScript with a SQL builder and no codegen** — if the\nask says `pgTable`, `drizzle-kit`, or `drizzle.config.ts`, that is `..\u002Fdrizzle-orm\u002FSKILL.md`,\nnot here.\n\nPrisma 7 has four non-negotiables. Get these wrong and nothing runs:\n\n1. **Generator is `provider = \"prisma-client\"` and `output` is REQUIRED.** The client is no\n   longer emitted into `node_modules` — you import it from your generated path. The legacy\n   `prisma-client-js` generator is gone.\n2. **A driver adapter is REQUIRED on the constructor.** `new PrismaClient({ adapter })`. Omit\n   it and you get `requires either adapter or accelerateUrl` at runtime.\n3. **Connection config lives in `prisma.config.ts`, not the datasource block.** `url`,\n   `directUrl`, `shadowDatabaseUrl` in `schema.prisma` are deprecated in v7.\n4. **Rust-free by default.** The query engine is TypeScript now — no native binaries, ~3x\n   faster queries, ~90% smaller bundles. `binaryTargets` no longer exists.\n\nVersion note: stable is the **7.x** line — latest stable is 7.7.0 (2026-04-07) per the\n[Prisma changelog](https:\u002F\u002Fwww.prisma.io\u002Fchangelog) (accessed 2026-06-02); pin `>=7.7`.\n\"Prisma Next\" — the future fully-TS foundation, first announced 2026-03-04 in\n[The Next Evolution of Prisma ORM](https:\u002F\u002Fwww.prisma.io\u002Fblog\u002Fthe-next-evolution-of-prisma-orm)\n— reached **Early Access in May 2026** per the\n[Prisma Next Roadmap](https:\u002F\u002Fwww.prisma.io\u002Fblog\u002Fprisma-next-roadmap) (2026-03-20, accessed\n2026-06-02). Early Access is forward-looking only and **not** the install default; for\nproduction work stay on stable 7.x.\n\n## Install & config\n\nInstall the CLI, the client, and the adapter for your database. One adapter per DB.\n\n```bash\n# Postgres\nnpm i -D prisma\nnpm i @prisma\u002Fclient @prisma\u002Fadapter-pg\n# others: @prisma\u002Fadapter-better-sqlite3, -libsql, -mariadb, -mssql, -d1\n```\n\nMinimal `schema.prisma` — note the generator shape and the **no-url datasource**:\n\n```prisma\ngenerator client {\n  provider = \"prisma-client\"\n  output   = \"..\u002Fsrc\u002Fgenerated\u002Fprisma\" \u002F\u002F REQUIRED in v7\n}\n\ndatasource db {\n  provider = \"postgresql\" \u002F\u002F url moved to prisma.config.ts\n}\n```\n\n`prisma.config.ts` holds the connection (replaces `url` in the datasource):\n\n```ts\nimport \"dotenv\u002Fconfig\";\nimport { defineConfig } from \"prisma\u002Fconfig\";\n\nexport default defineConfig({\n  schema: \"prisma\u002Fschema.prisma\",\n  migrations: { seed: \"tsx prisma\u002Fseed.ts\" },\n  datasource: { url: process.env.DATABASE_URL! },\n});\n```\n\n`package.json` scripts:\n\n```json\n{\n  \"scripts\": {\n    \"db:generate\": \"prisma generate\",\n    \"db:migrate\": \"prisma migrate dev\",\n    \"db:deploy\": \"prisma migrate deploy\",\n    \"db:seed\": \"prisma db seed\"\n  }\n}\n```\n\n## Model the schema\n\n`schema.prisma` is the single source of truth. Every relation needs an explicit FK field and\nan index on that FK column — Prisma does **not** index foreign keys for you, and a join on an\nunindexed column is a sequential scan.\n\n```prisma\nmodel User {\n  id        String   @id @default(cuid())\n  email     String   @unique\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  role      Role     @default(MEMBER)\n  posts     Post[]\n}\n\nmodel Post {\n  id        String   @id @default(cuid())\n  title     String\n  body      String   @db.Text \u002F\u002F native type\n  published Boolean  @default(false)\n  author    User     @relation(fields: [authorId], references: [id])\n  authorId  String\n  createdAt DateTime @default(now())\n\n  @@index([authorId])            \u002F\u002F index the FK you join\u002Ffilter on\n  @@unique([authorId, title])    \u002F\u002F composite uniqueness\n}\n\nenum Role {\n  ADMIN\n  MEMBER\n}\n```\n\n```prisma\n\u002F\u002F Bad: relation with no index on the FK — every join scans the table\nmodel Post {\n  author   User   @relation(fields: [authorId], references: [id])\n  authorId String\n}\n\u002F\u002F Good: add @@index([authorId]) — see the model above.\n```\n\n## Instantiate the client\n\n**One `PrismaClient` per process.** A new client per request opens a fresh connection pool\neach time and exhausts the database. In dev, pin it to `globalThis` so HMR reuses one instance.\n\n```ts\nimport { PrismaClient } from \"..\u002Fgenerated\u002Fprisma\u002Fclient\";\nimport { PrismaPg } from \"@prisma\u002Fadapter-pg\";\n\nconst adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });\n\nconst globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };\nexport const prisma =\n  globalForPrisma.prisma ??\n  new PrismaClient({ adapter, log: [\"query\"] }); \u002F\u002F log surfaces emitted SQL\n\nif (process.env.NODE_ENV !== \"production\") globalForPrisma.prisma = prisma;\n```\n\n```ts\n\u002F\u002F Bad: no adapter → throws \"requires either adapter or accelerateUrl\"\nexport const prisma = new PrismaClient();\n\u002F\u002F Bad: per-request instance → connection-pool exhaustion\napp.get(\"\u002Fu\", () => new PrismaClient({ adapter }).user.findMany());\n```\n\n## Query safely\n\nThree rules cover most query bugs:\n\n- **Prefer `select` over `include`.** `select` returns only the named fields; `include` adds a\n  relation but otherwise returns **all** scalar fields (over-fetch). Never put `select` and\n  `include` at the same level — Prisma rejects it.\n- **Always pass `take` to `findMany`.** It is unbounded by default and will happily stream the\n  whole table.\n- **Never query inside a loop.** Batch with `where: { id: { in: ids } }`.\n\n```ts\n\u002F\u002F Good: shape the row, bound the read\nconst users = await prisma.user.findMany({\n  take: 20,\n  where: { role: \"MEMBER\" },\n  select: { id: true, email: true, posts: { select: { title: true } } },\n});\n```\n\n```ts\n\u002F\u002F Bad: N queries in a loop\nfor (const id of ids) {\n  await prisma.user.findUnique({ where: { id } });\n}\n\u002F\u002F Good: one query\nconst users = await prisma.user.findMany({ where: { id: { in: ids } } });\n```\n\nPagination — pick by table size:\n\n| Need | Use | Why |\n| --- | --- | --- |\n| Small\u002Fmedium set, jump to page N | `skip` + `take` (offset) | Simple; `skip` gets slow on huge offsets |\n| Large set, infinite scroll, stable | `cursor` + `take` | Seeks by indexed id, constant cost |\n\nWrites: `upsert` for create-or-update; `createMany({ data, skipDuplicates: true })` for bulk.\n\nTransactions — pick by dependency:\n\n| Situation | Form |\n| --- | --- |\n| Independent writes that must all commit | `prisma.$transaction([opA, opB])` (array) |\n| Read, branch on the result, then write | `prisma.$transaction(async (tx) => { … })` (interactive) |\n\nLean on generated types instead of hand-writing shapes: `Prisma.UserGetPayload\u003C…>` and\n`Prisma.validator` keep a query and its type in sync. See\n`references\u002Fqueries-and-performance.md` for the full cookbook.\n\n## Performance: kill N+1 and over-fetch\n\n`relationLoadStrategy` decides how relations load:\n\n- `\"join\"` (default) — one query: a LATERAL JOIN with JSON aggregation on Postgres (correlated\n  subqueries on MySQL). This is the N+1 killer. The top-level choice cascades to nested loads.\n- `\"query\"` — one query per relation, joined in the app. Sometimes wins when a join fans out\n  rows badly.\n\n```ts\nconst feed = await prisma.user.findMany({\n  relationLoadStrategy: \"join\",\n  take: 20,\n  select: { id: true, email: true, posts: { select: { id: true, title: true } } },\n});\n```\n\nThen: `select` only the fields you render, and `@@index` the columns you filter and order on.\nTo see what Prisma actually emits, set `log: [\"query\"]` on the client and read the SQL. For\nthe deep perf checklist (N+1 detection, index selection, reading the plan) see\n`references\u002Fqueries-and-performance.md`. For `EXPLAIN ANALYZE`, index theory, and pool sizing\n— that is the database engine's job: `..\u002Fpostgresdb\u002FSKILL.md`.\n\n## Raw SQL safely\n\nUse raw SQL **only** through the tagged-template form — it parameterizes. The `*Unsafe`\nvariants concatenate strings and open SQL injection.\n\n```ts\n\u002F\u002F Good: parameterized tagged template\nconst rows = await prisma.$queryRaw`SELECT id FROM \"User\" WHERE email = ${email}`;\n\n\u002F\u002F Bad: interpolated string into the Unsafe API → SQL injection\nconst rows = await prisma.$queryRawUnsafe(`SELECT id FROM \"User\" WHERE email = '${email}'`);\n```\n\nCompose fragments with `Prisma.sql` \u002F `Prisma.join`. For fully type-checked results, write\n`.sql` files and use `$queryRawTyped`. Safety matrix in\n`references\u002Fqueries-and-performance.md`.\n\n## Migrations\n\nPick the command by environment — this is the most common mix-up:\n\n| Command | Use where | Does |\n| --- | --- | --- |\n| `prisma migrate dev` | **development only** | Creates a migration, applies it, regenerates the client; uses a shadow DB |\n| `prisma migrate deploy` | **CI \u002F production** | Applies pending migrations only — never generates, never resets |\n| `prisma db push` | prototyping \u002F spikes | Syncs schema to the DB with **no** migration file |\n\nRules with teeth:\n\n- **Never run `migrate dev` against production.** It can reset the database.\n- **Never edit a migration that has already been applied.** Create a new one.\n- A shadow DB lets `migrate dev` detect drift; it must be a separate, disposable database.\n- On drift or a failed migration, use `prisma migrate resolve --applied|--rolled-back`.\n- Seed via the `seed` entry in `prisma.config.ts` and `prisma db seed`.\n\nFailed-migration recovery, baselining an existing database, and the full Prisma 6 to 7\nupgrade are in `references\u002Fmigrations-and-v7-upgrade.md`. For ORM-independent evolution\nstrategy (expand\u002Fcontract, dual-write, zero-downtime backfills) that is\n`..\u002Fdb-migrations\u002FSKILL.md`.\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n| --- | --- | --- |\n| `new PrismaClient()` with no adapter | v7 throws `requires either adapter or accelerateUrl` | Pass a driver adapter |\n| New `PrismaClient` per request | Pool exhaustion, dropped connections | One instance per process; `globalThis` in dev |\n| `prisma-client-js` generator | Legacy v6 generator, removed in v7 | `provider = \"prisma-client\"` + `output` |\n| `binaryTargets` in the generator | Rust-era artifact; v7 is Rust-free | Delete it |\n| Unbounded `findMany()` | Streams the whole table | Always pass `take` (and `cursor` for paging) |\n| Fat `include` everywhere | Over-fetches every scalar | `select` only the rendered fields |\n| Query inside a `for` loop | N+1 round trips | Batch `where: { id: { in: ids } }` or `relationLoadStrategy: \"join\"` |\n| `$queryRawUnsafe(\\`…${x}…\\`)` | SQL injection | Tagged `$queryRaw\\`…${x}\\`` |\n| `migrate dev` in CI\u002Fprod | Can reset the production DB | `migrate deploy` |\n| Editing an applied migration | Drift, broken history | New migration; `migrate resolve` for drift |\n| FK with no `@@index` | Joins do sequential scans | `@@index([fkColumn])` |\n\n## Verify\n\nRun `scripts\u002Fverify.sh \u003Cpath>` to statically check emitted artifacts: it confirms the\n`prisma-client` generator + `output`, an adapter on the constructor, and flags\n`$queryRawUnsafe` injection, `binaryTargets`, unbounded `findMany`, and wrong-ORM\ncontamination. Read-only; no database connection.\n",{"name":5,"tags":24,"origin":31,"recommends":32,"description":7},[25,5,26,27,28,29,30],"prisma","typescript-orm","prisma-migrate","schema","migrations","orm","risco",[33,34,35,36,37,38,39,40,41],"drizzle-orm","db-migrations","postgresdb","neon","planetscale","supabase","sqlite-turso","typescript","sql","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fprisma-orm",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill prisma-orm",{"tool":56,"command":57},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill prisma-orm",{"tool":59,"command":60},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill prisma-orm","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fprisma-orm\u002FSKILL.md",true,[64,70,74,78],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"evals\u002Fcases.yaml","REFERENCE","参考文档",3358,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fprisma-orm\u002Fevals\u002Fcases.yaml",{"path":71,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":72,"sourceHtmlUrl":73},"evals\u002FREADME.md",889,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fprisma-orm\u002Fevals\u002FREADME.md",{"path":75,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fmigrations-and-v7-upgrade.md",6886,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fprisma-orm\u002Freferences\u002Fmigrations-and-v7-upgrade.md",{"path":79,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fqueries-and-performance.md",7159,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fprisma-orm\u002Freferences\u002Fqueries-and-performance.md",[83,91,96,103,110,117],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":90},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":92,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":90},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":90},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":90},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":90},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":90},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]