Skip to content

Commit

Permalink
Clear database from GPN 2023 on upgrade.
Browse files Browse the repository at this point in the history
+ Related: d142e56.
  • Loading branch information
johnjohndoe committed May 16, 2024
1 parent 07b8ee1 commit 9acb01b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class AlarmsDBOpenHelper extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 6;
private static final int DATABASE_VERSION = 7;

private static final String DATABASE_NAME = "alarms";

Expand Down Expand Up @@ -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 < 7) {
// Clear database from GPN 2023.
db.execSQL("DROP TABLE IF EXISTS " + AlarmsTable.NAME);
onCreate(db);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class HighlightDBOpenHelper extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 5;
private static final int DATABASE_VERSION = 6;

private static final String DATABASE_NAME = "highlight";

Expand All @@ -32,7 +32,7 @@ public void onCreate(SQLiteDatabase db) {

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Clear database from 36C3 2019.
// Clear database from GPN 2023.
db.execSQL("DROP TABLE IF EXISTS " + HighlightsTable.NAME);
onCreate(db);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
if (oldVersion < 9) {
boolean columnExists = SQLiteDatabaseExtensions.columnExists(db, MetasTable.NAME, Columns.SCHEDULE_LAST_MODIFIED);
if (!columnExists) {
db.execSQL("ALTER TABLE " + MetasTable.NAME + " ADD COLUMN " +
Columns.SCHEDULE_LAST_MODIFIED + " TEXT DEFAULT ''");
}
// Clear database from GPN 2023.
db.execSQL("DROP TABLE IF EXISTS " + MetasTable.NAME);
onCreate(db);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class SessionsDBOpenHelper extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 15;
private static final int DATABASE_VERSION = 14;

private static final String DATABASE_NAME = "lectures"; // Keep table name to avoid database migration.

Expand Down Expand Up @@ -153,18 +153,11 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
if (oldVersion < 14) {
boolean columnExists = SQLiteDatabaseExtensions.columnExists(db, SessionsTable.NAME, Columns.ROOM_IDENTIFIER);
if (!columnExists) {
db.execSQL("ALTER TABLE " + SessionsTable.NAME + " ADD COLUMN " + Columns.ROOM_IDENTIFIER + " TEXT DEFAULT ''");
}
}
if (oldVersion < 15) {
boolean columnExists = SQLiteDatabaseExtensions.columnExists(db, SessionsTable.NAME, Columns.FEEDBACK_URL);
if (!columnExists) {
db.execSQL("ALTER TABLE " + SessionsTable.NAME + " ADD COLUMN " + Columns.FEEDBACK_URL + " TEXT DEFAULT NULL");
}
// Clear database from GPN 2023.
db.execSQL("DROP TABLE IF EXISTS " + SessionsTable.NAME);
db.execSQL("DROP TABLE IF EXISTS " + SessionByNotificationIdTable.NAME);
onCreate(db);
}


}
}

0 comments on commit 9acb01b

Please sign in to comment.