Keep existing POP3 messages

This commit is contained in:
M66B 2022-05-07 19:00:48 +02:00
parent 4e2108f0a2
commit a80cb2ceee
2 changed files with 2767 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 233,
version = 234,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2324,6 +2324,25 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN 'conditions' TEXT");
}
}).addMigrations(new Migration(233, 234) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("UPDATE account" +
" SET max_messages = MAX(max_messages," +
" (SELECT COUNT(*) FROM folder" +
" JOIN message ON message.folder = folder.id" +
" WHERE folder.account = account.id" +
" AND folder.type = '" + EntityFolder.INBOX + "'" +
" AND NOT message.ui_hide))" +
" WHERE pop = " + EntityAccount.TYPE_POP +
" AND NOT max_messages IS NULL");
}
}).addMigrations(new Migration(234, 233) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {