title: golang -> gorm: How I can use sql.NullInt64 to be int(10) in mysql?
body: <pre><code>type Contact struct {
    gorm.Model
    PersonID sql.NullInt64
  }
  
  type Person struct {
    gorm.Model
  }
  </code></pre>
  
  <p>I am trying to use <a href="http://jinzhu.me/gorm/" rel="nofollow noreferrer">gorm</a> with mysql in the previuos code but I have the following problem:</p>
  
  <p>I want:</p>
  
  <ul>
  <li>Use <code>sql.NullInt64</code> to work easily with null values.</li>
  <li>Use the base model definition <code>gorm.Model</code>, including fields <code>ID</code>, <code>CreatedAt</code>, <code>UpdatedAt</code>, <code>DeletedAt</code>.</li>
  <li>Add a constraint <code>Db.Model(&amp;models.Contact{}).AddForeignKey</code>.</li>
  </ul>
  
  <p>My problem:</p>
  
  <ul>
  <li><code>Person.ID</code> become <code>"int(10)"</code> in mysql.</li>
  <li><code>Contact.PersonID</code> become <code>"bigint(20)"</code></li>
  <li>MySql need the same type for <a href="https://stackoverflow.com/questions/16969060/mysql-error-1215-cannot-add-foreign-key-constraint/16969176#16969176">pk and fk</a>.</li>
  </ul>
  
  <p>Some body can help me to solve this?</p>