diff options
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java | 18 |
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 |