title: How to insert a null foreign key in gorm?
body: <p>I have a transaction table in gorm that looks like this:</p>
  <pre><code>type Transaction struct {
      gorm.Model
      UserID      string `gorm:&quot;index&quot;`
      TradeID     int 
      Trade       Trade
      ExternalID  string
      Amount      float32
      Type        string
      Description string
  }
  </code></pre>
  <p>And I'm trying to insert a transaction without a trade:</p>
  <pre><code>DB.Create(&amp;Transaction{UserID: &quot;user-1&quot;, Type: &quot;unblock&quot;, Amount:  50})
  </code></pre>
  <p>This fails because the Transaction structs defaults the int value of the key to 0 so the insert fails at the db level because I don't have a trade with id = 0.</p>
  <p>How can I do this?</p>