Modern Apps git

← Modern-Apps.git

securemail: migrate outbox v1 to v2 (drop opt-in column)

Commit
7fcef93d39e0c1377b7e286ffb67bb2f91f4c2ab
Author
vayun-mathur <[email protected]>
When
2026-10-24 01:03 UTC (1 month ago)
Parents
5f25a19

Diff

securemail/src/main/java/com/vayunmathur/securemail/data/MailDatabase.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/data/MailDatabase.kt b/securemail/src/main/java/com/vayunmathur/securemail/data/MailDatabase.ktindex 9810a22a26..a2e35a9b4a 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/data/MailDatabase.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/data/MailDatabase.kt@@ -112,7 +112,7 @@ interface OutboxDao {  @Database(     entities = [StoredMessage::class, CachedKey::class, OutboxMessage::class],-    version = 1,+    version = 2,     exportSchema = false, ) abstract class MailDatabase : RoomDatabase() {@@ -121,6 +121,38 @@ abstract class MailDatabase : RoomDatabase() {     abstract fun outboxDao(): OutboxDao      companion object : DatabaseMigrations {-        override val migrations: List<Migration> = emptyList()+        /**+         * v1 → v2: drops the `sendUnencrypted` column from OutboxMessage (the+         * explicit opt-in was removed — keyless recipients always go out+         * plaintext now). SQLite has no DROP COLUMN on older devices, so the+         * table is rebuilt; outbox rows are transient retries, safe to carry+         * over by column list.+         */+        private val MIGRATION_1_2 = Migration(1, 2) {+            it.execSQL(+                """+                CREATE TABLE IF NOT EXISTS `OutboxMessage_new` (+                    `rowId` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,+                    `toJson` TEXT NOT NULL,+                    `subject` TEXT NOT NULL,+                    `body` TEXT NOT NULL,+                    `inReplyTo` TEXT,+                    `createdMillis` INTEGER NOT NULL,+                    `lastError` TEXT,+                    `attemptCount` INTEGER NOT NULL DEFAULT 0+                )+                """.trimIndent(),+            )+            it.execSQL(+                "INSERT INTO OutboxMessage_new " ++                    "(rowId, toJson, subject, body, inReplyTo, createdMillis, lastError, attemptCount) " ++                    "SELECT rowId, toJson, subject, body, inReplyTo, createdMillis, lastError, attemptCount " ++                    "FROM OutboxMessage",+            )+            it.execSQL("DROP TABLE OutboxMessage")+            it.execSQL("ALTER TABLE OutboxMessage_new RENAME TO OutboxMessage")+        }++        override val migrations: List<Migration> = listOf(MIGRATION_1_2)     } }