Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
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
13 changes: 2 additions & 11 deletions app/src/common/shared/org/mozilla/vrbrowser/db/AppDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
.addCallback(new Callback() {
@Override
public void onCreate(@NonNull SupportSQLiteDatabase db) {
Expand Down Expand Up @@ -87,19 +87,10 @@ public void migrate(SupportSQLiteDatabase database) {
}
};

private static final Migration MIGRATION_1_3 = new Migration(1, 3) {
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE PopUpSite RENAME TO SitePermission");
database.execSQL("ALTER TABLE SitePermission ADD COLUMN category INTEGER NOT NULL DEFAULT 0");
database.execSQL("ALTER TABLE SitePermission ADD COLUMN principal STRING NOT NULL DEFAULT ''");
}
};

private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE SitePermission ADD COLUMN principal STRING NOT NULL DEFAULT ''");
database.execSQL("ALTER TABLE SitePermission ADD COLUMN principal TEXT NOT NULL DEFAULT ''");
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public SitePermission(@NonNull String url, @NonNull String principal, @Category
this.url = url;
this.principal = principal;
this.category = category;
this.allowed = false;
}

@PrimaryKey(autoGenerate = true)
Expand All @@ -29,9 +30,12 @@ public SitePermission(@NonNull String url, @NonNull String principal, @Category
public String url;

@NonNull
@ColumnInfo(name = "principal")
@ColumnInfo(name = "principal", defaultValue = "")
public String principal;

@ColumnInfo(name = "allowed")
public boolean allowed;

@ColumnInfo(name = "category")
public @Category int category;
}
Expand Down