1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 01:36:55 +00:00

Migrate encrypt flag

This commit is contained in:
M66B 2019-11-17 13:09:19 +01:00
parent 676342e66d
commit dd81823fea

View file

@ -56,7 +56,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 113, version = 114,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -1102,6 +1102,16 @@ public abstract class DB extends RoomDatabase {
db.execSQL("CREATE INDEX IF NOT EXISTS `index_revision_message` ON `revision` (`message`)"); db.execSQL("CREATE INDEX IF NOT EXISTS `index_revision_message` ON `revision` (`message`)");
db.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS `index_revision_message_sequence` ON `revision` (`message`, `sequence`)"); db.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS `index_revision_message_sequence` ON `revision` (`message`, `sequence`)");
} }
})
.addMigrations(new Migration(113, 114) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("UPDATE message SET encrypt = 1 WHERE id IN " +
"(SELECT DISTINCT message FROM attachment" +
" WHERE encryption = " + EntityAttachment.PGP_MESSAGE + ")");
}
}) })
.build(); .build();
} }