package com.fsck.k9.mailstore.migrations;


import android.database.sqlite.SQLiteDatabase;


public class MigrationTo55 {
    public static void createFtsSearchTable(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
        db.execSQL("CREATE VIRTUAL TABLE messages_fulltext USING fts4 (fulltext)");
    }
}

@@ -48,262 +48,2186 @@
 ort 
-android.database.sqlite.SQLiteDatabase;%0A%0A%0Apublic class MigrationTo55 %7B%0A    public static void createFtsSearchTable(SQLiteDatabase db, MigrationsHelper migrationsHelper) %7B%0A        db.execSQL(%22CREATE VIRTUAL TABLE messages_fulltext USING fts4 (fulltext)%22);
+java.util.Collections;%0Aimport java.util.List;%0A%0Aimport android.content.ContentValues;%0Aimport android.database.sqlite.SQLiteDatabase;%0Aimport android.util.Log;%0A%0Aimport com.fsck.k9.K9;%0Aimport com.fsck.k9.mail.FetchProfile;%0Aimport com.fsck.k9.mail.MessagingException;%0Aimport com.fsck.k9.mailstore.LocalFolder;%0Aimport com.fsck.k9.mailstore.LocalMessage;%0Aimport com.fsck.k9.mailstore.LocalStore;%0Aimport com.fsck.k9.message.extractors.MessageFulltextCreator;%0A%0A%0Apublic class MigrationTo55 %7B%0A    public static void createFtsSearchTable(SQLiteDatabase db, MigrationsHelper migrationsHelper) %7B%0A        db.execSQL(%22CREATE VIRTUAL TABLE messages_fulltext USING fts4 (fulltext)%22);%0A%0A        LocalStore localStore = migrationsHelper.getLocalStore();%0A%0A        try %7B%0A            List%3CLocalFolder%3E folders = localStore.getPersonalNamespaces(true);%0A            ContentValues cv = new ContentValues();%0A            FetchProfile fp = new FetchProfile();%0A            fp.add(FetchProfile.Item.BODY);%0A            for (LocalFolder folder : folders) %7B%0A                List%3CLocalMessage%3E localMessages = folder.getMessages(null, false);%0A                for (LocalMessage localMessage : localMessages) %7B%0A                    folder.fetch(Collections.singletonList(localMessage), fp, null);%0A                    MessageFulltextCreator fulltextCreator = localStore.getMessageFulltextCreator();%0A                    String fulltext = fulltextCreator.createFulltext(localMessage);%0A                    if (fulltext != null) %7B%0A                        Log.d(K9.LOG_TAG, %22fulltext for msg id %22 + localMessage.getId() + %22 is %22 + fulltext.length() + %22 chars long%22);%0A                        cv.clear();%0A                        cv.put(%22docid%22, localMessage.getId());%0A                        cv.put(%22fulltext%22, fulltext);%0A                        db.insert(%22messages_fulltext%22, null, cv);%0A                    %7D else %7B%0A                        Log.d(K9.LOG_TAG, %22no fulltext for msg id %22 + localMessage.getId() + %22 :(%22);%0A                    %7D%0A                %7D%0A            %7D%0A        %7D catch (MessagingException e) %7B%0A            Log.e(K9.LOG_TAG, %22error indexing fulltext - skipping rest, fts index is incomplete!%22, e);%0A        %7D
 %0A   

add simple migration path