title: How do I specify a boxed field can be nullable in my Realm migration code?
body: <p>I'm using <strong>Kotlin</strong> and I want to add a new field to a <code>RealmObject</code> and that field can be nullable. Here's what I have in my migration:</p>
  
  <pre><code>val schema = realm.schema.get(ZOLA_NOTIFICATION)
  if (!(schema?.hasField("agentId") ?: false)) {
      schema.addField("agentId", Long::class.java)
  }
  </code></pre>
  
  <p>However, I receive an error message when this migration is run:</p>
  
  <pre><code>Non-fatal Exception: io.realm.exceptions.RealmMigrationNeededException
  Field 'agentId' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'agentId' or migrate using RealmObjectSchema.setNullable().
  </code></pre>
  
  <p>How do I specify that the <code>Long::class.java</code> should be the nullable type in the migration code?</p>