Automated summary
This skill guides use of Prisma Migrate (dev, deploy, reset, resolve, diff) to evolve a database schema and manage migration history.
Strengths
- Covers the full lifecycle: development, production deployment, reset, and resolving failed migrations
- Explains baselining an existing database with migrate diff and migrate resolve
- Details the shadow database mechanism and drift detection
- Flags common mistakes such as running migrate dev in CI or deleting migration files
Limitations
- Provides no built-in rollback strategy, only manual reverse migrations
- Assumes prior familiarity with Prisma and relational databases
- Instructions stay general and do not cover provider-specific database quirks
Use it when you need to apply, deploy, or troubleshoot Prisma migrations on an existing project.
Avoid it for rapid prototyping without migration history, where prisma db push fits better.
Security analysis
CautionThe skill is a legitimate Prisma Migrate reference and does not attempt exfiltration, obfuscation, or safety bypass. However, it documents powerful database operations, including a reset command that drops the database, so it warrants caution rather than a pure safe rating.
- •Includes `npx prisma migrate reset`, which drops and recreates the database; explicitly marked development-only but still destructive if pointed at the wrong database.
- •Includes manual migration-history operations (`migrate resolve --applied` / `--rolled-back`) that can mask a failed migration if used without verifying database state.
- •No allowed-tools are declared, but the document assumes shell access and execution of `npx prisma` commands that modify database state.
Examples
I added a `status` field to my User model in schema.prisma. Generate and apply the Prisma migration with a descriptive name.Show me the correct command to apply all pending Prisma migrations to my production database without generating new ones.My Postgres database already has tables and I want to adopt Prisma Migrate. Walk me through baselining it with migrate diff and migrate resolve.Prisma Migrations
Manage database schema evolution with prisma migrate dev/deploy/reset and migration history
When to Use
- Applying schema changes to the database during development
- Deploying migrations to staging or production environments
- Baselining an existing database for Prisma Migrate adoption
- Resolving migration history conflicts or drift
Instructions
- Development workflow — after editing
schema.prisma, run:
npx prisma migrate dev --name describe_the_change
This generates a migration SQL file, applies it, and regenerates Prisma Client.
- Production deployment — never use
migrate devin production. Use:
npx prisma migrate deploy
This applies all pending migrations without generating new ones.
- Reset the database (development only) — drops the database, recreates it, applies all migrations, and runs the seed script:
npx prisma migrate reset
- Baseline an existing database — when adopting Prisma Migrate on a database that already has tables:
mkdir -p prisma/migrations/0_init
npx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > prisma/migrations/0_init/migration.sql
npx prisma migrate resolve --applied 0_init
- Check for drift between the schema and the database:
npx prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma
-
Customize generated SQL — after
migrate devcreates a migration file, edit it before committing. Prisma will not overwrite your edits on subsequent runs. -
Handle failed migrations — if a migration partially applied:
# Fix the database state manually, then mark as applied:
npx prisma migrate resolve --applied MIGRATION_NAME
# Or mark as rolled back:
npx prisma migrate resolve --rolled-back MIGRATION_NAME
- Shadow database —
migrate devrequires a shadow database to detect drift. Configure it explicitly if your provider does not allow automatic creation:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
-
Always commit migration files (
prisma/migrations/) to version control. They are the source of truth for production. -
Never delete or reorder migration directories once they have been applied to any environment.
Details
Prisma Migrate uses a migrations table (_prisma_migrations) to track which migrations have been applied. Each migration is a directory containing a migration.sql file and is applied in lexicographic order.
Migration history vs schema state: The migration history is the authoritative record. The schema file describes the desired end state. If these diverge (drift), migrate dev will detect it via the shadow database.
Shadow database mechanics: During migrate dev, Prisma creates a temporary shadow database, applies all existing migrations to it, computes the diff against your schema, and generates the new migration. The shadow database is dropped afterward. This means you need CREATE DATABASE privileges in development.
Data migrations: Prisma generates only DDL (schema changes). If you need DML (data changes — backfills, column value transforms), add raw SQL to the generated migration file before committing.
Trade-offs:
migrate devis safe and reversible (viareset), but slow on large schemas due to shadow database overheadmigrate deployis fast but irreversible — there is no built-in rollback. Write reverse migrations manually if neededdb pushskips migration history entirely — use it only for rapid prototyping, never in a shared environment
Common mistakes:
- Running
migrate devin CI — it generates files and requires a shadow database. Usemigrate deployinstead - Deleting migration files to "clean up" — this breaks the migration history for any database that already applied them
- Not testing migrations on a copy of production data before deploying — column type changes or NOT NULL additions can fail on existing data
Source
https://prisma.io/docs/orm/prisma-migrate
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/prisma-migrations-mrx3xypm/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/prisma-migrations-mrx3xypm' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/prisma-migrations-mrx3xypm/download' --output '.skill-downloads/prisma-migrations-mrx3xypm/SKILL.md.part' && mv '.skill-downloads/prisma-migrations-mrx3xypm/SKILL.md.part' '.skill-downloads/prisma-migrations-mrx3xypm/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.
Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/prisma-migrations-mrx3xypm/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.