Not able to deploy model after datamodel updates


#1

Created some records baed on below model and after that add a new filed url: String!and trying to prisma deploy, getting this error:

**Item**

✖ You are creating a new required unique field **`url`** . There are already nodes for the model **`Item`** that would violate that constraint.

How do I add/update fields in datamodel :disappointed_relieved: :question:

type Item {
  id: ID! @id
  title: String!
  tags: [String!]!
  logo: Image
  createdBy: User! @relation(name: "CreatedItems")
  likes: [User!]! @relation(name: "LikedItems")
  comments: [Comment!]!
  description: String
}

#2

I found the answer so, replying myself.

  1. Add new field url without make it required and prisma deploy. (url: String).
    It will add a new field to every entry with null value.

  2. Now use updateMany query and update url field with it’s respective data type like blank string ("") or ("default_value").

  3. Update data model again and make url field not null this time with exclamation mark. (url: String!)

  4. Now you new field url become not null type.[quote=“kumar.gulshan80, post:1, topic:7770, full:true”]
    Created some records baed on below model and after that add a new filed url: String!and trying to prisma deploy, getting this error:

    Item

    :heavy_multiplication_x: You are creating a new required unique field url . There are already nodes for the model Item that would violate that constraint.

How do I add/update fields in datamodel :disappointed_relieved: :question:

type Item {
  id: ID! @id
  title: String!
  tags: [String!]!
  logo: Image
  createdBy: User! @relation(name: "CreatedItems")
  likes: [User!]! @relation(name: "LikedItems")
  comments: [Comment!]!
  description: String
}

[/quote]


Where `null` is throwing error, not able to update/delete records
#3

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.