Skip to content

Commit

Permalink
Fix Database crash between v10 versions (#3345)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed May 8, 2020
1 parent 04d5517 commit fb0babb
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -13,7 +13,7 @@

import org.mozilla.vrbrowser.AppExecutors;

@Database(entities = {SitePermission.class}, version = 3)
@Database(entities = {SitePermission.class}, version = 4)
public abstract class AppDatabase extends RoomDatabase {

private static final String DATABASE_NAME = "app";
Expand All @@ -38,7 +38,7 @@ public static AppDatabase getAppDatabase(Context context, final AppExecutors exe
@NonNull
private static AppDatabase buildDatabase(final @NonNull Context appContext, final @NonNull AppExecutors executors) {
return Room.databaseBuilder(appContext, AppDatabase.class, DATABASE_NAME)
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
.addMigrations(MIGRATION_1_2, MIGRATION_2_4)
.addCallback(new Callback() {
@Override
public void onCreate(@NonNull SupportSQLiteDatabase db) {
Expand Down Expand Up @@ -87,7 +87,8 @@ public void migrate(SupportSQLiteDatabase database) {
}
};

private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
// Note: We skip version 3 as a workaround to fix a crash between v10 releases
private static final Migration MIGRATION_2_4 = new Migration(2, 4) {
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE SitePermission ADD COLUMN principal TEXT NOT NULL DEFAULT ''");
Expand Down

0 comments on commit fb0babb

Please sign in to comment.