A running prisma dev does not apply a migration planned after contract emit; migrations/ is not watched

Abierto
#470 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, postgresql, typescript

Línea de trabajo

Start with packages/0-framework/3-tooling/cli/src/operations/execute-dev.ts and packages/0-framework/3-tooling/cli/src/entry-resolution.ts, where the issue traces the watched-file list to firstResult.appFiles and recordAppFiles. Follow how postgres() resources expose their migration paths and how a file change triggers a rebuild. Done means planning or changing a migration under migrations/ while prisma dev runs triggers the migration to apply without restarting.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Composer 0.40.0, prisma 8.0.0-rc.36, @prisma/orm-postgres 8.0.0-rc.25, macOS, Node.js 24.13.0, Bun 1.3.13. The scratch app is the one in the issue about prisma dev not moving the db ref.

Reproduced on 2026-11-30 in the same scratch app (state: two migrations applied, init and add_author), with prisma dev running in the foreground (./node_modules/.bin/prisma dev, dev: ready).

  1. Add tag String? to Quote in contract.prisma, then run ./node_modules/.bin/prisma contract emit (prints storageHash: 7f07db7a2d8ed53ccea5a0f6a663ed5cc7df39ea96808cd5ff6f225c00ddc0d7). The running dev rebuilds at once and the rebuild's converge fails, as expected for a contract with no migration yet:
✘ rebuild 1
Converge failed; the running app is untouched and dev is still watching.
OrmMigrationError: Prisma ORM migrate (MIGRATION_PATH_NOT_FOUND): The committed migrations/ directory has no authored path from the database's current schema (68a11edd3f76d3812ccb19d59671c91e9c24b2b1dbc178f287c01668a95d1047) to the target — the deploy pipeline only replays authored migrations, it never creates schema itself. Iterating locally? Bring the database along with `prisma db update`. Shipping? Author the migration path — …
  1. Plan the migration. Because of defect 1 the bare command fails, so this step names its origin: ./node_modules/.bin/prisma migration plan --name add-tag --from 20261130T0437_add_author. It writes migrations/app/20261130T0516_add_tag (ALTER TABLE "public"."Quote" ADD COLUMN "tag" text;).

  2. Wait 30 seconds. The running dev prints nothing more: no rebuild starts. The column is not there:

psql "$(./node_modules/.bin/prisma dev url quotes-app.database)" -Atc "select column_name from information_schema.columns where table_name='Quote' order by 1"
author
id
text

Only a restart of prisma dev applies the migration (shown for add_author in defect 1).

Why, from source (v0.40.0): dev watches the built output and every app file the entry imports (packages/0-framework/3-tooling/cli/src/operations/execute-dev.ts lines 778-800, watchedDefinitions from firstResult.appFiles; packages/0-framework/3-tooling/cli/src/entry-resolution.ts recordAppFiles). contract.json is imported by src/data.ts, so a contract emit triggers a rebuild, which re-runs the migration step and fails because the migration is not written yet. migrations/ is never imported, so it is not watched, and the migration planned next does not trigger a rebuild. The designed loop (emit, then plan) therefore never reaches a running dev's database. Expected: a change under migrations/ of a postgres() resource also triggers a rebuild (or dev applies migrations some other way while running).

Found while writing the Composer docs on prisma.io (prisma/web#8965). The docs do not work around this.

Lenguaje dominante
TypeScript
Estrellas
6
Forks
2
Merge medio
1 d 2 h
PR fusionados (30 d)
33

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de prisma/composer

Todos los issues de prisma/composer

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.