`prisma format` remembers old columns/relations and re-adds them

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
cli, database, tooling

Direzione di ricerca

Reproduce the issue with the shown schema.prisma and prisma format, then compare the result after deleting the local prisma/migrations/2026...my_migration folder. Start by locating the prisma format entry point and its schema or migration state handling. Done means deleted relations and columns stay absent after formatting, including for models not yet present in the database.

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

Descrizione

Summary

When I run prisma format, it doesn't just format my schema.prisma file, it also adds columns and relations which I've recently deleted.

Scenario

I have the following model:

model foobars {
  id          BigInt  @id @default(autoincrement())
  name        String  @db.Text
  lorem_ipsu  String  @db.Text
  lorem       String  @db.Text
  description String? @db.Text

  @@schema("foo")
}

When I run prisma format, it becomes the following (for the sake of brevity, I won't paste the related models here):

model foobars {
  id          BigInt   @id @default(autoincrement())
  name        String   @db.Text
  lorem_ipsu  String   @db.Text
  lorem       String   @db.Text
  description String?  @db.Text
  amets       amets?   @relation(fields: [ametsId], references: [id])
  ametsId     BigInt?
  dolores     options? @relation(fields: [doloresId], references: [id])
  doloresId   Int?
  ipsums      ipsums?  @relation(fields: [ipsumsId], references: [id])
  ipsumsId    Int?

  @@schema("foo")
}

All the relations and columns added by Prisma used to exist on the model, but I've deleted them.
Note that those are all new models which don't exist in my actual database yet.

One non-standard thing I've done which might have had some impact is that I had created the migration locally with prisma migrate dev --create-only --name my-migration, didn't apply it, then deleted the prisma/migrations/2026...my_migration folder so that I could work some more on my migration then generate a new file.

This may be the same issue as https://github.com/prisma/language-tools/issues/1800

Version

Prisma 7.8.0

Lingua principale
TypeScript
Stelle
21
Fork
2
Merge medio
23h 23m
PR unite (30g)
40

Guida per i contributori

Apri la guida per i contributori

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/prisma-cli

Tutte le issue di prisma/prisma-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.