Skip to content

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

Description

@TanguyP

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 prisma/language-tools#1800

Version

Prisma 7.8.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions