0

Good day all, can you help figure this out, I am getting an error that ‘cannot be executed’ even after running npx prisma generate as well as npx prisma migrate dev. If the question mark "?" is removed and I try 'migrating' the errors I am getting is as follows:

model Creative {
  id             Int      @id @default(autoincrement())
  stock_id       String   @default(cuid())
  parent_id      String   @default(cuid())
  hostelMenu     String?
  inStock        String?

}

//Error:
:warning: We found changes that cannot be executed:

  • Step 0 Made the column `hostelMenu` on table `Creative` required, but there are 1 existing NULL values.
  • Step 0 Made the column `inStock` on table `Creative` required, but there are 1 existing NULL values.

You can use prisma migrate dev --create-only to create the migration file, and manually modify it to address the underlying issue(s).
Then run prisma migrate dev to apply it and verify it works.

Chrissy
  • 45
  • 2
  • 6

1 Answers1

0

You are getting this error because you are trying to make an optional column required and there is data in the database that has null values for those columns. You can run npx prisma migrate dev --create-only to create the migration file. In the migration file you will have to write some extra sql, either adding data to the records that are missing data or dropping the records with missing data.