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.
Asked
Active
Viewed 1,422 times
1

Damia Fuentes
- 5,308
- 6
- 33
- 65
2 Answers
4
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.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
2What a pitty... I hope this feature will be added in the future to have it as simple as in Django. – Kev Apr 15 '18 at 10:52
1
If you're looking at this in 2021, android room implementation of anything higher than 2.4.0-alpha01 now supports auto migrations. More information here: https://developer.android.com/training/data-storage/room/migrating-db-versions

Vytenis Bučius
- 147
- 1
- 4