How many methods will I have to make for Room migration if I have db version 10?
I looked into the following example Google Persistence Migration Sample
and I found Migration varargs based on probable scenarios for database version 4.
public static UsersDatabase getInstance(Context context) {
synchronized (sLock) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
UsersDatabase.class, "Sample.db")
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_1_4)
.build();
}
return INSTANCE;
}
}
My question is, Suppose I am using Room from the db v1 and by time my app reaches to db v10, how many migration methods will I have to write?
In sqlite, we get current db version of installed app in onUpgrade and we just fall through switch case without break statements so that it satisfies all db upgrades.
However, I am not sure, but afaik, we cannot get current db version of installed app in room, we write all possible methods for migration.
But it feels so inconvenient, inappropriate to write total 45 methods if I have db v10!
Is there any better solution?