title: How to prevent Child models from Deletion in Golang GORM?
body: <p>Well, I would like to know, Is there any solutions, how to prevent Child Model from deletion in foreignKey Constraint, (</p>
  <p>For example in <code>gorm</code> there is a couple of options that allows to restrict behavior of the Parent Model after deletion, and Delete or Set to Null the Child Model Objects That has foreignKey relation (onDelete: Cascade / Set Null, and the same thing for onUpdate)</p>
  <p>// Pretty a lot of the same words, but I hope you got it :)</p>
  <p>Little Example.. from Golang ...</p>
  <pre><code>
  type SomeOtherStruct struct {
       gorm.Model
       Id int 
  
  } 
  
  type SomeModel struct {
      gorm.Model
      someOtherStructId string 
  
      someField SomeOtherStruct `gorm:&quot;foreignKey:SomeOtherStructId; OnDelete:Cascade,OnUpdate: SET NULL&quot;` // basically foreign Key Relationship to model `SomeOtherStruct`
  }
  
  </code></pre>
  <p>But I would like to prevent any Update/Deletion behavior, so Child Relation Models Objects won't get deleted after the Parent Model Object has been..</p>
  <p>There is actually a concept from Django Framework (Python)</p>
  <pre><code>class SomeModel(models.Model):
       
      some_field = models.ForeignKey(to=AnotherModel,   verbose_name=&quot;SomeField&quot;, on_delete=models.PROTECT) 
  
  class AnotherModel(models.Model):
       pass 
  
  </code></pre>
  <p>As you can see, there is <code>models.PROTECT</code> constraint, that is basically what I'm looking for....</p>
  <p>Is there any analogy for that in Golang GORM or some <code>RAW SQL</code> for that as well?</p>
  <p>Thanks..</p>