Remove FolderClass.NONE

Rewrite entries in the database to use FolderClass.NO_CLASS
This commit is contained in:
cketti 2020-04-08 19:23:16 +02:00
parent de2f0a37ef
commit a44732ee38
4 changed files with 20 additions and 3 deletions

View file

@ -12,7 +12,7 @@ import timber.log.Timber;
class StoreSchemaDefinition implements SchemaDefinition {
static final int DB_VERSION = 70;
static final int DB_VERSION = 71;
private final MigrationsHelper migrationsHelper;

View file

@ -0,0 +1,16 @@
package com.fsck.k9.storage.migrations
import android.database.sqlite.SQLiteDatabase
internal class MigrationTo71(private val db: SQLiteDatabase) {
fun cleanUpFolderClass() {
db.execSQL("UPDATE folders SET poll_class = 'NO_CLASS' " +
"WHERE poll_class NOT IN ('NO_CLASS', 'INHERITED', 'FIRST_CLASS', 'SECOND_CLASS')")
db.execSQL("UPDATE folders SET push_class = 'NO_CLASS' " +
"WHERE push_class NOT IN ('NO_CLASS', 'INHERITED', 'FIRST_CLASS', 'SECOND_CLASS')")
db.execSQL("UPDATE folders SET display_class = 'NO_CLASS' " +
"WHERE display_class NOT IN ('NO_CLASS', 'INHERITED', 'FIRST_CLASS', 'SECOND_CLASS')")
db.execSQL("UPDATE folders SET notify_class = 'NO_CLASS' " +
"WHERE notify_class NOT IN ('NO_CLASS', 'INHERITED', 'FIRST_CLASS', 'SECOND_CLASS')")
}
}

View file

@ -27,6 +27,8 @@ public class Migrations {
new MigrationTo69(db).createPendingDelete();
case 69:
new MigrationTo70(db).removePushState();
case 70:
new MigrationTo71(db).cleanUpFolderClass();
}
}
}

View file

@ -1,6 +1,5 @@
package com.fsck.k9.mail;
// NONE is obsolete, it will be translated to NO_CLASS for display and to INHERITED for sync and push
public enum FolderClass {
NONE, NO_CLASS, INHERITED, FIRST_CLASS, SECOND_CLASS
NO_CLASS, INHERITED, FIRST_CLASS, SECOND_CLASS
}