title: Realm migration with new schema
body: <p>I have an app which already taken use of a realm database. I now want to add a new RealmObject to the schema (say I want to add <code>Person</code> as my new RealmObject class). From the documentation it looks like I need to do the following to make this work:  </p>
  
  <pre><code>RealmConfiguration config = new RealmConfiguration.Builder()
  .schemaVersion(1) // Must be bumped when the schema changes
  .migration(new MyMigration()) // Migration to run instead of throwing an exception
  .build()
  
  
  
  
  // Example migration adding a new class
  class MyMigration extends RealmMigration {
  
    @Override
    public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
         // DynamicRealm exposes an editable schema
         RealmSchema schema = realm.getSchema();
  
         // Migrate to version 1: Add a new class.
         // Example:
         // public Person extends RealmObject {
         //     private String name;
         //     private int age;
         //     // getters and setters left out for brevity
         // }
         if (oldVersion == 0) {
            schema.create("Person")
                .addField("name", String.class)
                .addField("age", int.class);
            oldVersion++;
         }
         etc.... 
  </code></pre>
  
  <p>My question here: do we really need to create the <code>Person</code> schema "by hand" (i.e. add the fields, with their type) here? Or is there a way to use the <code>Person</code> RealmObject since we have already defined what fields should belong to the new class there</p>