From 2a9b20c3c6bcc4451ff1af4dcc1f04030bcba0bc Mon Sep 17 00:00:00 2001 From: Tobias Preuss Date: Sun, 27 Aug 2023 06:44:27 +0200 Subject: [PATCH] Clear database from MRMCD 2019 on upgrade. + Related database state: 65048ea8dc0b7d3d0a482563dc72f412fb0515ee. --- .../sqliteopenhelper/AlarmsDBOpenHelper.java | 7 ++++++- .../sqliteopenhelper/HighlightDBOpenHelper.java | 2 +- .../sqliteopenhelper/MetaDBOpenHelper.java | 7 ++++++- .../sqliteopenhelper/SessionsDBOpenHelper.java | 14 +++----------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.java b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.java index 34114bca2f..d4d485140f 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.java +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/AlarmsDBOpenHelper.java @@ -10,7 +10,7 @@ public class AlarmsDBOpenHelper extends SQLiteOpenHelper { - private static final int DATABASE_VERSION = 6; + private static final int DATABASE_VERSION = 8; private static final String DATABASE_NAME = "alarms"; @@ -62,5 +62,10 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + AlarmsTable.NAME); onCreate(db); } + if (oldVersion < 8) { + // Clear database from MRMCD 2019. + db.execSQL("DROP TABLE IF EXISTS " + AlarmsTable.NAME); + onCreate(db); + } } } diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.java b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.java index c81e524a35..81b7523326 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.java +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/HighlightDBOpenHelper.java @@ -11,7 +11,7 @@ public class HighlightDBOpenHelper extends SQLiteOpenHelper { - private static final int DATABASE_VERSION = 5; + private static final int DATABASE_VERSION = 7; private static final String DATABASE_NAME = "highlight"; diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.java b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.java index 68903b4082..a5b77344ea 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.java +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/MetaDBOpenHelper.java @@ -12,7 +12,7 @@ public class MetaDBOpenHelper extends SQLiteOpenHelper { - private static final int DATABASE_VERSION = 8; + private static final int DATABASE_VERSION = 9; private static final String DATABASE_NAME = "meta"; @@ -64,5 +64,10 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + MetasTable.NAME); onCreate(db); } + if (oldVersion < 9) { + // Clear database from MRMCD 2019. + db.execSQL("DROP TABLE IF EXISTS " + MetasTable.NAME); + onCreate(db); + } } } diff --git a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.java b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.java index b4cdcec82e..7747a1b540 100644 --- a/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.java +++ b/database/src/main/java/info/metadude/android/eventfahrplan/database/sqliteopenhelper/SessionsDBOpenHelper.java @@ -16,7 +16,7 @@ public class SessionsDBOpenHelper extends SQLiteOpenHelper { - private static final int DATABASE_VERSION = 13; + private static final int DATABASE_VERSION = 11; private static final String DATABASE_NAME = "lectures"; // Keep table name to avoid database migration. @@ -132,20 +132,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { if (oldVersion < 10 && newVersion >= 10) { db.execSQL(SESSION_BY_NOTIFICATION_ID_TABLE_CREATE); } - if (oldVersion < 11 && newVersion >= 11) { + if (oldVersion < 11) { boolean columnExists = SQLiteDatabaseExtensions.columnExists(db, SessionsTable.NAME, Columns.TIME_ZONE_OFFSET); if (!columnExists) { db.execSQL("ALTER TABLE " + SessionsTable.NAME + " ADD COLUMN " + Columns.TIME_ZONE_OFFSET + " INTEGER DEFAULT NULL"); } - } - if (oldVersion < 12) { - // Clear database from rC3 12/2020. - db.execSQL("DROP TABLE IF EXISTS " + SessionsTable.NAME); - db.execSQL("DROP TABLE IF EXISTS " + SessionByNotificationIdTable.NAME); - onCreate(db); - } - if (oldVersion < 13) { - // Clear database from rC3 NOWHERE 12/2021. + // Clear database from MRMCD 2019. db.execSQL("DROP TABLE IF EXISTS " + SessionsTable.NAME); db.execSQL("DROP TABLE IF EXISTS " + SessionByNotificationIdTable.NAME); onCreate(db);