Loading app/storage/src/main/java/com/fsck/k9/storage/StoreSchemaDefinition.java +4 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import timber.log.Timber; class StoreSchemaDefinition implements SchemaDefinition { static final int DB_VERSION = 66; static final int DB_VERSION = 67; private final MigrationsHelper migrationsHelper; Loading Loading @@ -93,7 +93,8 @@ class StoreSchemaDefinition implements SchemaDefinition { "notify_class TEXT default '"+ Folder.FolderClass.INHERITED.name() + "', " + "more_messages TEXT default \"unknown\", " + "server_id TEXT, " + "local_only INTEGER" + "local_only INTEGER, " + "type TEXT DEFAULT \"regular\"" + ")"); db.execSQL("DROP INDEX IF EXISTS folder_server_id"); Loading app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo67.kt 0 → 100644 +27 −0 Original line number Diff line number Diff line package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase import com.fsck.k9.mailstore.MigrationsHelper internal object MigrationTo67 { @JvmStatic fun addTypeColumnToFoldersTable(db: SQLiteDatabase, migrationsHelper: MigrationsHelper) { db.execSQL("ALTER TABLE folders ADD type TEXT DEFAULT \"regular\"") val account = migrationsHelper.account setFolderType(db, account.inboxFolder, "inbox") setFolderType(db, account.outboxFolder, "outbox") setFolderType(db, account.trashFolder, "trash") setFolderType(db, account.draftsFolder, "drafts") setFolderType(db, account.spamFolder, "spam") setFolderType(db, account.sentFolder, "sent") setFolderType(db, account.archiveFolder, "archive") } private fun setFolderType(db: SQLiteDatabase, serverId: String?, type: String) { if (serverId != null) { db.execSQL("UPDATE folders SET type = ? WHERE server_id = ?", arrayOf(type, serverId)) } } } app/storage/src/main/java/com/fsck/k9/storage/migrations/Migrations.java +2 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ public class Migrations { MigrationTo65.addLocalOnlyColumnToFoldersTable(db, migrationsHelper); case 65: MigrationTo66.addEncryptionTypeColumnToMessagesTable(db); case 66: MigrationTo67.addTypeColumnToFoldersTable(db, migrationsHelper); } if (shouldBuildFtsTable) { Loading app/storage/src/test/java/com/fsck/k9/storage/StoreSchemaDefinitionTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import android.database.sqlite.SQLiteDatabase; import android.text.TextUtils; import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.core.BuildConfig; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.MessagingException; Loading Loading @@ -371,6 +372,12 @@ public class StoreSchemaDefinitionTest extends K9RobolectricTest { private Account createAccount() { Account account = mock(Account.class); when(account.getInboxFolder()).thenReturn("Inbox"); when(account.getOutboxFolder()).thenReturn(Account.OUTBOX); when(account.getTrashFolder()).thenReturn("Trash"); when(account.getDraftsFolder()).thenReturn("Drafts"); when(account.getSpamFolder()).thenReturn("Spam"); when(account.getSentFolder()).thenReturn("Sent"); when(account.getArchiveFolder()).thenReturn(null); when(account.getLocalStorageProviderId()).thenReturn(StorageManager.InternalStorageProvider.ID); when(account.getStoreUri()).thenReturn("dummy://"); return account; Loading Loading
app/storage/src/main/java/com/fsck/k9/storage/StoreSchemaDefinition.java +4 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import timber.log.Timber; class StoreSchemaDefinition implements SchemaDefinition { static final int DB_VERSION = 66; static final int DB_VERSION = 67; private final MigrationsHelper migrationsHelper; Loading Loading @@ -93,7 +93,8 @@ class StoreSchemaDefinition implements SchemaDefinition { "notify_class TEXT default '"+ Folder.FolderClass.INHERITED.name() + "', " + "more_messages TEXT default \"unknown\", " + "server_id TEXT, " + "local_only INTEGER" + "local_only INTEGER, " + "type TEXT DEFAULT \"regular\"" + ")"); db.execSQL("DROP INDEX IF EXISTS folder_server_id"); Loading
app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo67.kt 0 → 100644 +27 −0 Original line number Diff line number Diff line package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase import com.fsck.k9.mailstore.MigrationsHelper internal object MigrationTo67 { @JvmStatic fun addTypeColumnToFoldersTable(db: SQLiteDatabase, migrationsHelper: MigrationsHelper) { db.execSQL("ALTER TABLE folders ADD type TEXT DEFAULT \"regular\"") val account = migrationsHelper.account setFolderType(db, account.inboxFolder, "inbox") setFolderType(db, account.outboxFolder, "outbox") setFolderType(db, account.trashFolder, "trash") setFolderType(db, account.draftsFolder, "drafts") setFolderType(db, account.spamFolder, "spam") setFolderType(db, account.sentFolder, "sent") setFolderType(db, account.archiveFolder, "archive") } private fun setFolderType(db: SQLiteDatabase, serverId: String?, type: String) { if (serverId != null) { db.execSQL("UPDATE folders SET type = ? WHERE server_id = ?", arrayOf(type, serverId)) } } }
app/storage/src/main/java/com/fsck/k9/storage/migrations/Migrations.java +2 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ public class Migrations { MigrationTo65.addLocalOnlyColumnToFoldersTable(db, migrationsHelper); case 65: MigrationTo66.addEncryptionTypeColumnToMessagesTable(db); case 66: MigrationTo67.addTypeColumnToFoldersTable(db, migrationsHelper); } if (shouldBuildFtsTable) { Loading
app/storage/src/test/java/com/fsck/k9/storage/StoreSchemaDefinitionTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import android.database.sqlite.SQLiteDatabase; import android.text.TextUtils; import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.core.BuildConfig; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.MessagingException; Loading Loading @@ -371,6 +372,12 @@ public class StoreSchemaDefinitionTest extends K9RobolectricTest { private Account createAccount() { Account account = mock(Account.class); when(account.getInboxFolder()).thenReturn("Inbox"); when(account.getOutboxFolder()).thenReturn(Account.OUTBOX); when(account.getTrashFolder()).thenReturn("Trash"); when(account.getDraftsFolder()).thenReturn("Drafts"); when(account.getSpamFolder()).thenReturn("Spam"); when(account.getSentFolder()).thenReturn("Sent"); when(account.getArchiveFolder()).thenReturn(null); when(account.getLocalStorageProviderId()).thenReturn(StorageManager.InternalStorageProvider.ID); when(account.getStoreUri()).thenReturn("dummy://"); return account; Loading