function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhijeet Purohit01Abhijeet Purohit01 

Problem in deleting master-detail field from Production.

I am trying to delete a master-detail field. It is referenced in 2 apex class files and a test_class file. This field is also a mandatory field. I am unable to delete it. How can I delete it?


I am using enterprise edition of


I tried:


1. Commenting the field in the test class, and the 2 apex classes. But the test class is displaying an error msg because required field is missing. So unable to save it.


As it is a mandatory field I cannot change the field type from Master-Detail to Look Up field.


2. I changed the field type from master-detail to lookup in sandbox and tried deploying the field into Production. But am getting an error msg as:


field integrity exception: unknown (must specify either cascade delete or restrict delete for master detail)



Can anyone help? Pls!


Hi Abhijeet,


There is one trick you can try, just comment out all the code of referenced class or that method in class and then try.


Abhijeet Purohit01Abhijeet Purohit01

How can I do that when the code is in Production?


I have to do it in Sandbox and then deploy it into Production. Finally, I should delete the field and again undo the changes in sandbox and deploy into Poduction.


But when I comment all the code of test class, in Sandbox, and try deploying it into Production, I am getting an error msg called: Required Field Missing.......