Synthèse automatique
Ce skill guide l'utilisation de Prisma Migrate (dev, deploy, reset, resolve, diff) pour faire évoluer un schéma de base de données et gérer l'historique des migrations.
Points forts
- Couvre le cycle complet : développement, déploiement en production, réinitialisation et résolution de migrations échouées
- Explique le baselining d'une base existante avec migrate diff et migrate resolve
- Détaille le mécanisme de la shadow database et la détection de drift
- Signale les erreurs courantes comme lancer migrate dev en CI ou supprimer des fichiers de migration
Limites
- Ne fournit pas de stratégie de rollback intégrée, seulement des migrations inverses manuelles
- Suppose une familiarité préalable avec Prisma et les bases de données relationnelles
- Les instructions restent générales et ne couvrent pas les spécificités de chaque fournisseur de base
À utiliser lorsqu'il faut appliquer, déployer ou dépanner des migrations Prisma sur un projet existant.
À éviter pour du prototypage rapide sans historique de migrations, où prisma db push est plus adapté.
Analyse de sécurité
PrudenceThe 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.
Exemples
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.
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/prisma-migrations-mrx3xypm/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
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. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Le fichier ne fournit pas un en-tête name/description exploitable pour cette procédure native. Le téléchargement reste disponible pour lecture ; utilisez le mode manuel ci-dessous.
Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/prisma-migrations-mrx3xypm/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.