Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fb0de1b authored by cketti's avatar cketti
Browse files

Add database migration to clear 'server_id' column of local folders

parent 1a96ef46
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ import timber.log.Timber;


class StoreSchemaDefinition implements SchemaDefinition {
    static final int DB_VERSION = 77;
    static final int DB_VERSION = 78;

    private final MigrationsHelper migrationsHelper;

+0 −17
Original line number Diff line number Diff line
package com.fsck.k9.storage.migrations

import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase

/**
 * Make sure local Outbox folder has correct 'server_id' value
 */
internal class MigrationTo77(private val db: SQLiteDatabase) {
    fun cleanUpOutboxServerId() {
        val values = ContentValues().apply {
            put("server_id", "K9MAIL_INTERNAL_OUTBOX")
        }

        db.update("folders", values, "name = 'Outbox' AND local_only = 1", null)
    }
}
+12 −0
Original line number Diff line number Diff line
package com.fsck.k9.storage.migrations

import android.database.sqlite.SQLiteDatabase

/**
 * Set 'server_id' value to NULL for local folders
 */
internal class MigrationTo78(private val db: SQLiteDatabase) {
    fun removeServerIdFromLocalFolders() {
        db.execSQL("UPDATE folders SET server_id = NULL WHERE local_only = 1")
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ object Migrations {
        if (oldVersion < 74) MigrationTo74(db, migrationsHelper.account).removeDeletedMessages()
        if (oldVersion < 75) MigrationTo75(db, migrationsHelper).updateAccountWithSpecialFolderIds()
        if (oldVersion < 76) MigrationTo76(db, migrationsHelper).cleanUpSpecialLocalFolders()
        if (oldVersion < 77) MigrationTo77(db).cleanUpOutboxServerId()
        // 77: No longer necessary
        if (oldVersion < 78) MigrationTo78(db).removeServerIdFromLocalFolders()
    }
}