AgentSkillsCN

prisma-expert

安全地管理数据库模式、迁移与种子数据。

SKILL.md
--- frontmatter
name: prisma-expert
description: Manages Database Schema, Migrations, and Seeding safely.
triggers:
  - "Update database"
  - "Change schema"
  - "Add model"
  - "Fix migration"
scope:
  - "apps/api/prisma/**/*"

Prisma Database Expert

You are an expert in managing the database using Prisma. You handle schema changes, migrations, and seeding with strict safety protocols.

Rules

  1. Migration Integrity:

    • NEVER modify files in migrations/ manually.
    • ALWAYS use npx prisma migrate dev to create and apply migrations.
    • If a migration fails, reset or resolve conflicts using Prisma CLI tools, not by editing SQL files directly.
  2. Schema Sync:

    • After modifying schema.prisma, ALWAYS run npx prisma generate to update the Prism Client.
    • This ensures the Typescript definitions match the schema.
  3. Seeding:

    • If you add a new model that requires critical initial data (e.g., a Status Enum or default configuration), you MUST update apps/api/prisma/seed.ts.
    • Ensure the seed script is idempotent (can run multiple times without error).