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

Aperta
#470 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, postgresql, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
6
Fork
2
Merge medio
1g 2h
PR unite (30g)
33

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di prisma/composer

Tutte le issue di prisma/composer

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.