From d18c99280e181c15354b9411809f73d6dafa7df1 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Thu, 9 Jul 2026 12:40:42 -0500 Subject: [PATCH] fix(yahoo): sync AccountDataMigrator DDL to AccountDatabase v3 (authError) AccountDataMigrator hardcoded the v2 accounts DDL (schema/2.json), so copyAccountTables created a table missing the authError column PR #472 added in v3 (schema/3.json). Room then rejected the pre-packaged accounts table as an invalid schema, failing every AccountDataMigratorTest instrumented test on every API level. Add `authError` TEXT to CREATE_TABLE_SQL["accounts"] to match the exported v3 schema exactly, and repoint the DDL-guard test (migratorDdlMatchesExportedAccountDatabaseSchema) at 3.json so it would have caught this drift. --- .../org/libremail/data/local/AccountDataMigratorTest.kt | 2 +- .../org/libremail/data/local/AccountDataMigrator.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt b/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt index 8db0847..6cd365c 100644 --- a/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt +++ b/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt @@ -275,7 +275,7 @@ class AccountDataMigratorTest { fun migratorDdlMatchesExportedAccountDatabaseSchema() { val schema = JSONObject( InstrumentationRegistry.getInstrumentation().context.assets - .open("org.libremail.data.local.AccountDatabase/2.json") + .open("org.libremail.data.local.AccountDatabase/3.json") .bufferedReader().use { it.readText() }, ).getJSONObject("database") val entities = schema.getJSONArray("entities") diff --git a/app/src/main/kotlin/org/libremail/data/local/AccountDataMigrator.kt b/app/src/main/kotlin/org/libremail/data/local/AccountDataMigrator.kt index af2423e..85d9a84 100644 --- a/app/src/main/kotlin/org/libremail/data/local/AccountDataMigrator.kt +++ b/app/src/main/kotlin/org/libremail/data/local/AccountDataMigrator.kt @@ -98,9 +98,9 @@ class AccountDataMigrator @Inject constructor( private val TABLES = listOf("accounts", "credentials", "account_settings", "signatures") /** - * DDL for the account tables in [AccountDatabase] v2, copied verbatim from the exported Room - * schema (`schemas/org.libremail.data.local.AccountDatabase/2.json` — v2 added `accounts.sortOrder`, - * issue #164). It MUST stay byte-for-byte identical to what Room generates for those entities, or + * DDL for the account tables in [AccountDatabase] v3, copied verbatim from the exported Room + * schema (`schemas/org.libremail.data.local.AccountDatabase/3.json` — v3 added `accounts.authError`, + * issue #362). It MUST stay byte-for-byte identical to what Room generates for those entities, or * Room silently accepts a subtly wrong schema (its identity check only compares the hash it writes, * not the pre-existing tables). * `AccountDataMigratorTest.migratorDdlMatchesExportedAccountDatabaseSchema` guards it against the @@ -110,7 +110,7 @@ class AccountDataMigrator @Inject constructor( "accounts" to "CREATE TABLE IF NOT EXISTS `accounts` (`id` TEXT NOT NULL, `email` TEXT NOT NULL, " + "`displayName` TEXT NOT NULL, `authType` TEXT NOT NULL, " + - "`sortOrder` INTEGER NOT NULL DEFAULT 0, `imap_host` TEXT NOT NULL, " + + "`sortOrder` INTEGER NOT NULL DEFAULT 0, `authError` TEXT, `imap_host` TEXT NOT NULL, " + "`imap_port` INTEGER NOT NULL, `imap_security` TEXT NOT NULL, `smtp_host` TEXT NOT NULL, " + "`smtp_port` INTEGER NOT NULL, `smtp_security` TEXT NOT NULL, PRIMARY KEY(`id`))", "credentials" to