Skip to content
Back to skills

Prisma Change

ASecurity

Guide through a full Prisma schema change workflow — edit schema, create migration, regenerate client, update affected services.

  • 30 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added June 8, 2026
developmenttypescriptbashsqlnodedatabase

Works with

  • cli

Security analysis

A100/100

Scanned June 8, 2026

npx -y skills add uxname/liteend --skill prisma-change --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prisma Change?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Prisma Change
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/uxname-prisma-change/badge)](https://www.skillsdirectory.com/skills/uxname-prisma-change)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: prisma-change
description: Guide through a full Prisma schema change workflow — edit schema, create migration, regenerate client, update affected services.
---

The user wants to modify the database schema in the project. This is a multi-step workflow where skipping any step causes runtime errors.

## Project-specific Prisma setup

- Schema: `prisma/schema.prisma`
- Generated client output: `src/@generated/prisma` (NOT the default `node_modules`)
- Import path in code: `import { ... } from '@/@generated/prisma/client'`
- Module format: CJS (set in generator config)
- Adapter: `@prisma/adapter-pg` (PostgreSQL)
- Migrations directory: `prisma/migrations/`

## The full workflow

### Step 1 — Edit `prisma/schema.prisma`

Apply the requested model/enum/field changes. Key conventions:
- All models have `id Int @id @default(autoincrement())`
- All models have `createdAt DateTime @default(now())` and `updatedAt DateTime @updatedAt`
- Use `String?` for optional strings, not empty string defaults
- Enum values are SCREAMING_SNAKE_CASE

### Step 2 — Create migration (dev only)

```bash
npm run db:migrations:create -- --name <migration-name>
```

This creates a new migration file in `prisma/migrations/` without applying it yet.
Use a descriptive kebab-case name, e.g. `add-user-email` or `add-posts-model`.

> In production, migrations are applied via `npm run db:migrations:apply` (runs `prisma migrate deploy`).
> In development, use `npm run db:push` only for fast prototyping (no migration file created).

### Step 3 — Regenerate Prisma client

```bash
npm run db:gen
```

This runs `prisma generate --no-hints` and outputs the client to `src/@generated/prisma`.
**Always run this after any schema change** — TypeScript types come from here.

### Step 4 — Update affected application code

After regenerating the client, check and update:
- Services that use `PrismaService` and reference the changed model
- GraphQL `@ObjectType` classes and Enums must be kept in sync manually. **CRITICAL:** Invoke the `/add-graphql-type` skill to scaffold or update the corresponding GraphQL types to match the new Prisma schema.
- Enum types in `types/*-role.enum.ts` or similar — must match Prisma enums

**Important:** The Prisma-generated types in `src/@generated/prisma/client` and the GraphQL `@ObjectType` classes are separate. The GraphQL types are NOT auto-generated — update them manually.

### Step 5 — Verify

```bash
npm run check
```

If it fails, do not proceed. Invoke the `/check` skill to diagnose and automatically fix linting, typing, or unused code errors, then return to this workflow.

## Common patterns

**Adding a field to an existing model:**
1. Add field to schema
2. Create migration: `npm run db:migrations:create -- --name add-<field>-to-<model>`
3. Regenerate: `npm run db:gen`
4. Update the corresponding `@ObjectType` class to add the `@Field()` decorator
5. Update any service methods that select or return the model

**Adding a new model:**
1. Add model to schema
2. Create migration: `npm run db:migrations:create -- --name add-<model-name>-model`
3. Regenerate: `npm run db:gen`
4. Create module files (use `/new-module` skill)

**Adding an enum:**
1. Add enum to schema
2. Add field referencing enum to the relevant model
3. Create migration
4. Regenerate client
5. Create enum file: `src/modules/<module>/types/<name>.enum.ts` with `registerEnumType`

## Enum file pattern

Use the `/add-graphql-type` skill for the enum file template and conventions.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.