facing named constraint problem when prisma migrating to version 5 from version 2

77 Views Asked by At

My project was using prisma version 2.11.0. Now, I want to upgrade it to latest version 5.4.1. Everything works great except named constraints. I have followed the instruction . As per instruction, I have done npx prisma db pull to reflect my db state to my schema file. Here is my schema:

model Domain {
  createdAt            DateTime  @default(now())
  updatedAt            DateTime  @updatedAt
  name                 String    @id @unique(map: "Domain.name_unique")
  account              String
  publicId             String    @unique(map: "Domain.publicId_unique") @default(uuid())
  externalId           String?
  eTag                 String?
  deleteOn             DateTime?
  dnsVerified          Boolean   @default(false)
  dkimVerified         Boolean   @default(false)
  lastDnsVerification  DateTime?
  lastDkimVerification DateTime?
  Page                 Page[]
}

However, once, I want to run npx prisma migrate dev, I get the following error:

Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

[*] Changed the `Domain` table
  [*] Renamed index `Domain_name_key` to `Domain.name_unique`
  [*] Renamed index `Domain_publicId_key` to `Domain.publicId_unique`
✔ We need to reset the "public" schema at "test_postgres_13:5432"
Do you want to continue? All data will be lost.

what can I do to prevent data loss? Thanks a lot for any kind of help.

0

There are 0 best solutions below