Communitygithub.com

Prisma 스키마 디자인, 마이그레이션 및 쿼리 최적화

Prisma 스키마 디자인, 마이그레이션 및 쿼리 최적화를 위한 스킬입니다.

Prisma 스키마 디자인, 마이그레이션 및 쿼리 최적화란 무엇인가요?

이 스킬은 Prisma ORM을 사용하는 개발자들을 위한 가이드로, 효율적인 스키마 디자인, 안전한 마이그레이션 관리, 그리고 고성능 쿼리 작성을 돕습니다. 핵심 규칙으로는 단일 진실 공급원(single source of truth)으로서의 `prisma/schema.prisma` 파일 관리, `include`보다 `select`를 우선 사용하여 필요한 필드만 가져오기, 다중 단계 변이에는 트랜잭션 사용, 소프트 삭제 패턴(`deletedAt DateTime?` 필드 + 미들웨어 필터) 적용, 자주 조회되는 필드에 인덱스 생성, 양방향 관계 정의 등이 포함됩니다. 또한 서버리스 환경을 위한 커넥션 풀링(Prisma Accelerate 또는 PgBouncer) 사용과 스키마 변경 후 타입 생성(`npx prisma generate`)을 권장합니다. 피해야 할 사항으로는 불필요한 `include`, N+1 쿼리, Prisma API로 처리 가능한 경우의 Raw SQL 사용, 페이지네이션 없이 `findMany()` 호출 등을 명시하여 성능 저하를 방지합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/prisma

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Prisma

규칙

  • 스키마는 prisma/schema.prisma에 위치 — 단일 진실 공급원
  • include보다 select 사용 — 필요한 필드만 가져오기
  • 다중 단계 변이에는 트랜잭션 사용: prisma.$transaction([...])
  • 소프트 삭제는 deletedAt DateTime? 필드 + 미들웨어 필터로 구현
  • 자주 조회되는 필드에 인덱스 생성: @@index([fieldName])
  • 관계: 항상 양쪽을 정의 (@relation)
  • 마이그레이션: npx prisma migrate dev --name 설명-이름
  • 서버리스 환경을 위한 커넥션 풀링: Prisma Accelerate 또는 PgBouncer 사용
  • 타입 생성: 스키마 변경 후 npx prisma generate

피해야 할 사항

  • 한 필드만 필요할 때 include: { relation: true } 사용 — 대신 select 사용
  • N+1 쿼리 — 중첩된 관계에는 include 또는 select 사용
  • Prisma API로 처리 가능할 때 Raw SQL 사용 — 복잡한 집계에만 $queryRaw 사용
  • prisma.table.findMany() 호출 시 take 제한 없이 사용 — 항상 페이지네이션 적용

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

관련 스킬