Skip to content
Snippets Groups Projects
Unverified Commit d6696305 authored by Jakob Möller's avatar Jakob Möller Committed by GitHub
Browse files

Integrate Schema Export for Upgrade Possibilities and Fallback Behavior for DB...

Integrate Schema Export for Upgrade Possibilities and Fallback Behavior for DB Migration Failure (#251)

Signed-off-by: default avatard067928 <jakob.moeller@sap.com>

Co-authored-by: default avatarHee Tatt Ooi <hee.tatt.ooi@sap.com>
parent ed0bafca
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,12 @@ android {
def VERIFICATION_CDN_URL = properties.getProperty('VERIFICATION_CDN_URL')
if (VERIFICATION_CDN_URL)
buildConfigField "String", "VERIFICATION_CDN_URL", "\"$VERIFICATION_CDN_URL\""
}
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
......@@ -202,7 +207,7 @@ dependencies {
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-guava:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.sqlite:sqlite:2.0.1"
implementation "androidx.sqlite:sqlite:2.1.0"
// UTILS
implementation project(":Server-Protocol-Buffer")
......
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "fc62bfe144d17a099180c8023c340138",
"entities": [
{
"tableName": "exposure_summary",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `daysSinceLastExposure` INTEGER NOT NULL, `matchedKeyCount` INTEGER NOT NULL, `maximumRiskScore` INTEGER NOT NULL, `summationRiskScore` INTEGER NOT NULL, `attenuationDurationsInMinutes` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "daysSinceLastExposure",
"columnName": "daysSinceLastExposure",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "matchedKeyCount",
"columnName": "matchedKeyCount",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "maximumRiskScore",
"columnName": "maximumRiskScore",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "summationRiskScore",
"columnName": "summationRiskScore",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "attenuationDurationsInMinutes",
"columnName": "attenuationDurationsInMinutes",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_exposure_summary_id",
"unique": false,
"columnNames": [
"id"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_exposure_summary_id` ON `${TABLE_NAME}` (`id`)"
}
],
"foreignKeys": []
},
{
"tableName": "date",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `path` TEXT NOT NULL, `type` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "path",
"columnName": "path",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_date_id",
"unique": false,
"columnNames": [
"id"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_date_id` ON `${TABLE_NAME}` (`id`)"
}
],
"foreignKeys": []
},
{
"tableName": "tracing_interval",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`from` INTEGER NOT NULL, `to` INTEGER NOT NULL, PRIMARY KEY(`from`, `to`))",
"fields": [
{
"fieldPath": "from",
"columnName": "from",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "to",
"columnName": "to",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"from",
"to"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_tracing_interval_from_to",
"unique": false,
"columnNames": [
"from",
"to"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_tracing_interval_from_to` ON `${TABLE_NAME}` (`from`, `to`)"
}
],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'fc62bfe144d17a099180c8023c340138')"
]
}
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ import java.io.File
@Database(
entities = [ExposureSummaryEntity::class, KeyCacheEntity::class, TracingIntervalEntity::class],
version = 1,
exportSchema = false
exportSchema = true
)
@TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() {
......@@ -52,6 +52,11 @@ abstract class AppDatabase : RoomDatabase() {
private fun buildDatabase(context: Context): AppDatabase {
return Room.databaseBuilder(context, AppDatabase::class.java, DATABASE_NAME)
/**
* The fallback behavior is to reset the app as we only store exposure summaries
* and cached references that are non-critical to app operation.
*/
.fallbackToDestructiveMigrationFrom()
.openHelperFactory(SupportFactory(SecurityHelper.getDBPassword()))
.build()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment