How to remove a type from datamodel.prisma


#1

After removing one type from datamodel.prisma I get an error when I run prisma deploy --force.

Is there any particular way how to remove a type from datamodel.prisma?

I had the followings.

type Teacher {
  id: ID! @unique
  email: String! @unique
  firstName: String!
  lastName: String!
  assignments: [Assignment!] @relation(name:"AssignmentToTeacher")
  advisee: [Student!] @relation(name:"StuentToTeacher")  
  advisory: Advisory @relation(name:"AdvisoryToTeacher")
  subjects: [Subject!]!
  updatedAt: DateTime!
  createdAt: DateTime!
}
...

type Advisory {
  id: ID! @unique
  teacher: Teacher! @relation(name:"AdvisoryToTeacher")
  grade: Int!
  updatedAt: DateTime!
  createdAt: DateTime!
}

I removed Advisory and now I have this.

type Teacher {
  id: ID! @unique
  email: String! @unique
  firstName: String!
  lastName: String!
  assignments: [Assignment!] @relation(name:"AssignmentToTeacher")
  advisees: [Student!] @relation(name:"StuentToTeacher")  
  subjects: [Subject!]!
  updatedAt: DateTime!
  createdAt: DateTime!
}

When I run prisma deploy --force, I get,

ERROR: Whoops. Looks like an internal server error. Search your server
logs for request ID: local:cjqlfqnke00050748f63v6vmm


#2

What I did was:

  1. Login Heroku and go to Settings of the database. And click Reset Database.
  2. docker container ls -a to see container ID
  3. docker stop 054221b066d4 to stop the container.
  4. docker container rm 054221b066d4 to remove the container.
  5. docker-compose up -d
  6. After few minutes, prisma deploy

Are there better ways to do?


#3

During development, if you do not care about data, I have found prisma delete to be much faster than prisma reset


#4

You can also use prisma reset -f and then try to deploy the new datamodel.