prisma-cli-migrate-dev

par prisma

prisma migrate dev. Référence lors de l'utilisation de cette fonctionnalité Prisma.

npx skills add https://github.com/prisma/cursor-plugin --skill prisma-cli-migrate-dev

prisma migrate dev

Creates and applies migrations during development. Requires a shadow database.

Command

prisma migrate dev [options]

What It Does

  1. Runs existing migrations in shadow database to detect drift
  2. Applies any pending migrations
  3. Generates new migration from schema changes
  4. Applies new migration to development database
  5. Updates _prisma_migrations table

Options

OptionDescription
--name / -nName the migration
--create-onlyCreate a new migration but do not apply it
--schemaCustom path to your Prisma schema
--configCustom path to your Prisma config file
--urlOverride the datasource URL from the Prisma config file

Removed in v7

  • --skip-generate - Run prisma generate explicitly
  • --skip-seed - Run prisma db seed explicitly

Examples

Create and apply migration

prisma migrate dev

Prompts for migration name if schema changed.

Named migration

prisma migrate dev --name add_users_table

Create without applying

prisma migrate dev --create-only

Useful for reviewing migration SQL before applying.

Full workflow (v7)

prisma migrate dev --name my_migration
prisma generate  # Must run explicitly in v7
prisma db seed   # Must run explicitly in v7

Migration Files

Created in prisma/migrations/:

prisma/migrations/
├── 20240115120000_add_users_table/
│   └── migration.sql
├── 20240116090000_add_posts/
│   └── migration.sql
└── migration_lock.toml

Schema Drift Detection

If migrate dev detects drift (manual database changes or edited migrations), it prompts to reset:

Drift detected: Your database schema is not in sync.

Do you want to reset your database? All data will be lost.

When to Use

  • Local development
  • Adding new models/fields
  • Changing relations
  • Creating indexes

When NOT to Use

  • Production deployments (use migrate deploy)
  • CI/CD pipelines (use migrate deploy)
  • MongoDB (use db push instead)

Common Patterns

After schema changes

// schema.prisma - Add new field
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  createdAt DateTime @default(now())  // New field
}
prisma migrate dev --name add_created_at

Handling data loss warnings

When a migration would cause data loss:

prisma migrate dev --name remove_field
# Warning: You are about to delete data...
# Accept with: --accept-data-loss

Shadow Database

migrate dev requires a shadow database for drift detection. Configure in prisma.config.ts:

export default defineConfig({
  datasource: {
    url: env('DATABASE_URL'),
    shadowDatabaseUrl: env('SHADOW_DATABASE_URL'),
  },
})

For local Prisma Postgres (prisma dev), shadow database is handled automatically.

Plus de skills de prisma

prisma-cli-migrate-reset
prisma
prisma migrate reset
official
prisma-cli-validate
prisma
Validation Prisma. Référence lors de l'utilisation de cette fonctionnalité Prisma.
official
prisma-next-extension-upgrade
prisma
Upgrade Prisma Next in your extension. Bumps every `@prisma-next/*` dependency to the requested target (or npm `latest`), runs the per-transition upgrade…
official
adr-review
prisma
Examiner un ou plusieurs ADR avec un regard neuf (en tant que membre de l’équipe sans contexte préalable), identifier les problèmes narratifs et structurels, puis les réécrire. À utiliser lorsque le…
official
prisma-next-upgrade
prisma
Upgrade Prisma Next in your app. Bumps every `@prisma-next/*` dependency from the version pinned in the lockfile to the requested target (or npm `latest`),…
official
prisma-cli
prisma
We need to translate the given text from English to French, preserving the name "prisma-cli" and other technical terms. The text is a description of a directory item for an agent skill. We must not add any extra commentary, labels, or formatting. Just the translation. The text: "Complete reference for Prisma CLI commands, options, and workflows across setup, migrations, and database operations. Covers 20+ commands organized by priority: setup ( init ), generation ( generate ), development ( dev ), database operations ( db pull/push/seed/execute ), and migrations ( migrate dev/deploy/reset/status/diff/resolve ) Includes Prisma 7.x changes: new prisma.config.ts configuration file, removed flags ( --skip-generate , --skip-seed , --schema , --url ), and explicit..." We need to translate into French. Keep technical terms like "Prisma CLI", "init", "generate", "dev", "db pull/push/seed/execute", "migrate dev/deploy/reset/status/diff/resolve
official
prisma-client-api
prisma
Référence complète de l'API Prisma Client pour les requêtes de modèle, les opérations CRUD, le filtrage, les relations et les transactions. Couvre 17 méthodes de requête de modèle, dont findUnique, findMany, create, update, delete, upsert et les opérations en masse avec variantes de retour. Fournit des options de requête pour façonner les résultats : select, include, omit, orderBy, take, skip, cursor et distinct. Inclut les opérateurs de filtre scalaires et logiques (equals, in, contains, startsWith, lt, gt) ainsi que les filtres de relation (some,...
official
prisma-compute
prisma
Prisma Compute deployment and hosting guide. Use whenever the user mentions Prisma Compute, `prisma.compute.ts`, `defineComputeConfig`, deploying or hosting a Prisma app, `@prisma/cli app deploy`, `compute:deploy`, `create-prisma --deploy`, `PRISMA_SERVICE_TOKEN`, `auth workspace`, Compute apps/deployments/build logs/domains, `@prisma/cli agent install`, localhost vs `0.0.0.0`, deploy port binding, or framework deploy readiness for Hono, Elysia, Next.js, TanStack Start, Astro, Nuxt, Svelte,...
developmentdevopsofficial