Room database migration if only new table is added : <p>Let't assume, I have a simple Room database:</p>

<pre><code>@Database(entities = {User.class}, version = 1)
abstract class AppDatabase extends RoomDatabase {
    public abstract Dao getDao();
}
</code></pre>

<p>Now, I'm adding a new entity: <code>Pet</code> and bumping version to 2:</p>

<pre><code>@Database(entities = {User.class, Pet.class}, version = 2)
abstract class AppDatabase extends RoomDatabase {
    public abstract Dao getDao();
}
</code></pre>

<p>Of course, Room throws an exception: <code>java.lang.IllegalStateException: A migration from 1 to 2 is necessary.</code></p>

<p>Assuming, I haven't changed <code>User</code> class (so all data is safe), I have to provide migration which just creates a new table. So, I'm looking into classes generated by Room, searching for generated query to create my new table, copying it and pasting into migration:</p>

<pre><code>final Migration MIGRATION_1_2 =
        new Migration(1, 2) {
            @Override
            public void migrate(@NonNull final SupportSQLiteDatabase database) {
                database.execSQL("CREATE TABLE IF NOT EXISTS `Pet` (`name` TEXT NOT NULL, PRIMARY KEY(`name`))");
            }
        };
</code></pre>

<p>However I find it inconvenient to do it manually.
Is there a way to tell Room: <em>I'm not touching any of the existing table, so data is safe. Please create migration for me?</em></p>
