Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix Database crash between v10 versions #3345

Merged
merged 1 commit into from
May 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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