Search code examples
androiddatabase-migrationandroid-roomautomatic-migration

Android Room automatic-migrations?


Is there a way of doing an automatic migration when needed with Room Persistance library in Android? Like Django migrations where you just execute makemigrations and migrate and it migrates automatically. It also increments the database version. And if there is a migration it cannot do, it tells/suggest you how to.


Solution

  • Room automatically runs migrations; there is no manual option to do so, outside of running tests. Room uses the standard SQLiteOpenHelper engine for this, and so it handles schema version tracking automatically as well.

    Room does not automatically create Migration classes with the migration code; you must write those yourself.