aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-26 22:58:03 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-26 22:58:03 +0100
commitce1302eec044d381e9781c3abe8211bc2d42d60a (patch)
tree03ecd99b1b9956577c169e20cf727b8cb8cb0033 /src/main/java/de/pixart/messenger/persistance
parent85a62901294d99d064fb24b72926f32b7c85e3c8 (diff)
fix compatibility issue on startup
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index 941ee6a47..02539c036 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -555,10 +555,26 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
if (oldVersion < 46 && newVersion >= 46) {
- db.execSQL("ALTER TABLE " + SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN " + SQLiteAxolotlStore.TRUSTED); // TODO - just to make old databases importable, column isn't needed at all
+ if (!isColumnExisting(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME, SQLiteAxolotlStore.TRUSTED)) {
+ db.execSQL("ALTER TABLE " + SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN " + SQLiteAxolotlStore.TRUSTED); // TODO - just to make old databases importable, column isn't needed at all
+ }
}
}
+ private boolean isColumnExisting(SQLiteDatabase db, String TableName, String ColumnName) {
+ boolean isExist = false;
+ Cursor cursor = db.rawQuery("PRAGMA table_info(" + TableName + ")", null);
+ cursor.moveToFirst();
+ do {
+ String currentColumn = cursor.getString(1);
+ if (currentColumn.equals(ColumnName)) {
+ isExist = true;
+ }
+ } while (cursor.moveToNext());
+ cursor.close();
+ return isExist;
+ }
+
private void canonicalizeJids(SQLiteDatabase db) {
// migrate db to new, canonicalized JID domainpart representation