title: How to correctly migrate to Embedded Objects in Realm?
body: <p>I would like to know, how to correctly migrate to Embedded Objects in Realm 10.0 update? Failed to find documentation for migration from ordinary RealmObject/RealmModel class to Embedded RealmObject/RealmModel class.</p>
  <p>Lets say, that I have parent class and child class, which connects to parent object by id:</p>
  <pre><code>public class MyParent extends RealmObject {
      @PrimaryKey
      private String id;
      private MyChild child; 
      // other fields...
  }
  public class MyChild extends RealmObject {
      @PrimaryKey
      private String id;
      private String parentId;
      // other fields...
  }
  </code></pre>
  <p>Experimentally I found, that I can:</p>
  <ul>
  <li>either (1a) guarantee that every embedded-candidate object in
  MyChild's table has single parent or (1b) clear model tables</li>
  <li>then (2) remove private key status from private field (&quot;id&quot;) &amp; remove field
  &quot;id&quot; itself from MyChild</li>
  <li>(3) set embedded status to MyChild class.</li>
  </ul>
  <p>In migration code it looks as follows:</p>
  <pre><code>realm.delete(&quot;MyParent&quot;);
  realm.delete(&quot;MyChild&quot;); // optional; variant (1b) is chosen
  
  schema.get(&quot;MyChild&quot;)
      .removePrimaryKey()
      .removeField(&quot;id&quot;);
      
  schema.get(&quot;MyChild&quot;).setEmbedded(true);
  </code></pre>
  <p>And it works.
  Am I right?</p>
  <p>P.S.</p>
  <ul>
  <li>Info &amp; examples about PR for Embedded Objects: <a href="https://github.com/realm/realm-java/pull/6730" rel="nofollow noreferrer">https://github.com/realm/realm-java/pull/6730</a></li>
  <li>Embedded Objects documentation: <a href="https://docs.mongodb.com/realm/android/embedded-objects/" rel="nofollow noreferrer">https://docs.mongodb.com/realm/android/embedded-objects/</a></li>
  </ul>