From b4835e6b91cc90287476f93b4b70e5641beae732 Mon Sep 17 00:00:00 2001 From: Tobias Preuss Date: Mon, 5 Aug 2024 16:11:40 +0200 Subject: [PATCH] Clear database from FrOSCon 2023 on upgrade. + Related datbase state: 86b8d1d59f203bf3b2eeaa6cd66508a507f66fc6. --- .../database/sqliteopenhelper/AlarmsDBOpenHelper.kt | 7 ++++++- .../sqliteopenhelper/HighlightDBOpenHelper.kt | 2 +- .../database/sqliteopenhelper/MetaDBOpenHelper.kt | 7 ++++++- .../sqliteopenhelper/SessionsDBOpenHelper.kt | 12 +++++------- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.kt b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.kt index 4d966f118..f1e1f1dae 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.kt +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.kt @@ -24,7 +24,7 @@ internal class AlarmsDBOpenHelper(context: Context) : SQLiteOpenHelper( ) { private companion object { - const val DATABASE_VERSION = 6 + const val DATABASE_VERSION = 12 const val DATABASE_NAME = "alarms" // language=sql @@ -68,6 +68,11 @@ internal class AlarmsDBOpenHelper(context: Context) : SQLiteOpenHelper( dropTableIfExist(NAME) onCreate(this) } + if (oldVersion < 12) { + // Clear database from FrOSCon 2023. + dropTableIfExist(NAME) + onCreate(this) + } } } diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.kt b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.kt index ca094cc45..d543cd065 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.kt +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.kt @@ -17,7 +17,7 @@ internal class HighlightDBOpenHelper(context: Context) : SQLiteOpenHelper( ) { private companion object { - const val DATABASE_VERSION = 5 + const val DATABASE_VERSION = 11 const val DATABASE_NAME = "highlight" // language=sql diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.kt b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.kt index 5b0df15ec..854a7025b 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.kt +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.kt @@ -24,7 +24,7 @@ internal class MetaDBOpenHelper(context: Context) : SQLiteOpenHelper( ) { private companion object { - const val DATABASE_VERSION = 9 + const val DATABASE_VERSION = 13 const val DATABASE_NAME = "meta" // language=sql @@ -75,6 +75,11 @@ internal class MetaDBOpenHelper(context: Context) : SQLiteOpenHelper( addTextColumn(SCHEDULE_LAST_MODIFIED, default = "") } } + if (oldVersion < 13) { + // Clear database from FrOSCon 2023. + dropTableIfExist(NAME) + onCreate(this) + } } } diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.kt b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.kt index 5b416fdf4..aeedc89a7 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.kt +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.kt @@ -109,7 +109,7 @@ internal class SessionsDBOpenHelper(context: Context) : SQLiteOpenHelper( ) { private companion object { - const val DATABASE_VERSION = 16 + const val DATABASE_VERSION = 15 const val DATABASE_NAME = "lectures" // Keep table name to avoid database migration. // language=sql @@ -291,12 +291,10 @@ internal class SessionsDBOpenHelper(context: Context) : SQLiteOpenHelper( } } if (oldVersion < 15) { - if (!columnExists(SessionsTable.NAME, FEEDBACK_URL)) { - addTextColumn(FEEDBACK_URL, default = null) - } - } - if (oldVersion < 16) { - execSQL(SCHEDULE_STATISTIC_VIEW_CREATE) + // Clear database from FrOSCon 2023. + dropTableIfExist(SessionsTable.NAME) + dropTableIfExist(SessionByNotificationIdTable.NAME) + onCreate(this) } }