Add missing indexes in new database migration step

This commit is contained in:
Philip Whitehouse 2017-01-31 12:51:47 +00:00
parent 0c5fedb504
commit 4a8d93b572
3 changed files with 44 additions and 1 deletions

View file

@ -153,7 +153,7 @@ public class LocalStore extends Store implements Serializable {
*/ */
private static final int THREAD_FLAG_UPDATE_BATCH_SIZE = 500; private static final int THREAD_FLAG_UPDATE_BATCH_SIZE = 500;
public static final int DB_VERSION = 58; public static final int DB_VERSION = 59;
public static String getColumnNameForFlag(Flag flag) { public static String getColumnNameForFlag(Flag flag) {

View file

@ -0,0 +1,41 @@
package com.fsck.k9.mailstore.migrations;
import android.database.sqlite.SQLiteDatabase;
class MigrationTo59 {
static void addMissingIndexes(SQLiteDatabase db) {
addMessageCompositeIndex(db);
addMessageEmptyIndex(db);
addMessageFlaggedIndex(db);
addMessageFolderIdDeletedDateIndex(db);
addMessageReadIndex(db);
addMessageUidIndex(db);
addMessageReadIndex(db);
}
private static void addMessageCompositeIndex(SQLiteDatabase db) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_composite ON messages (deleted, empty,folder_id,flagged,read)");
}
private static void addMessageEmptyIndex(SQLiteDatabase db) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_empty ON messages (empty)");
}
private static void addMessageFlaggedIndex(SQLiteDatabase db) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_flagged ON messages (flagged)");
}
private static void addMessageFolderIdDeletedDateIndex(SQLiteDatabase db) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_folder_id_deleted_date ON messages (folder_id,deleted,internal_date)");
}
private static void addMessageReadIndex(SQLiteDatabase db) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_read ON messages (read)");
}
private static void addMessageUidIndex(SQLiteDatabase db) {
db.execSQL("CREATE INDEX IF NOT EXISTS msg_uid ON messages (uid, folder_id)");
}
}

View file

@ -71,6 +71,8 @@ public class Migrations {
case 57: case 57:
MigrationTo58.cleanUpOrphanedData(db); MigrationTo58.cleanUpOrphanedData(db);
MigrationTo58.createDeleteMessageTrigger(db); MigrationTo58.createDeleteMessageTrigger(db);
case 58:
MigrationTo59.addMissingIndexes(db);
} }
} }
} }