Fix the caption database migration.

This commit is contained in:
Greyson Parrelli 2018-11-26 11:50:31 -08:00
parent 5d1fcdaded
commit 187d7b3e3a

View File

@ -58,8 +58,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int NOTIFICATION_CHANNELS = 12;
private static final int SECRET_SENDER = 13;
private static final int ATTACHMENT_CAPTIONS = 14;
private static final int ATTACHMENT_CAPTIONS_FIX = 15;
private static final int DATABASE_VERSION = 14;
private static final int DATABASE_VERSION = 15;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -299,6 +300,14 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE part ADD COLUMN caption TEXT DEFAULT NULL");
}
// 4.30.8 included a migration, but not a correct CREATE_TABLE statement, so we need to add
// this column if it isn't present.
if (oldVersion < ATTACHMENT_CAPTIONS_FIX) {
if (!columnExists(db, "part", "caption")) {
db.execSQL("ALTER TABLE part ADD COLUMN caption TEXT DEFAULT NULL");
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();