Skip to content

Commit d3dd422

Browse files
committed
fix(db): stop MIGRATION_13_14 creating indexes no entity declares
f0fca7b (in v1.7.37 and v1.7.38) added evidenceExpiresAt to SpamNumber and SpamPrefix without an @Index, but MIGRATION_13_14 also created index_spam_numbers_evidenceExpiresAt and index_spam_prefixes_evidenceExpiresAt. Room validates the schema after migrating, found indexes the entities don't have, threw "Migration didn't properly handle: spam_numbers" and rolled the upgrade back. A phone whose database was v13 or older therefore failed to open it on every launch after updating. Because validation always failed and rolled back, no database ever committed those indexes, so dropping the two CREATE INDEX statements fixes the path without a version bump. The column default '[]' left by ADD COLUMN is tolerated by Room's check (the entity declares no default). Verified on an API 35 emulator: the six instrumented AppDatabaseMigrationTest cases (v5, 6, 7, 8, 9 and 11 to current) all failed before the change and all pass after it. Nothing runs the instrumented suite, which is why this shipped; running the migration check in a JVM gate is now a P1 roadmap item. 1381 JVM tests pass; lint, ktlint and detekt are clean.
1 parent d66b6b1 commit d3dd422

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ All notable changes to CallShield will be documented in this file.
66

77
### Protection
88

9+
- Updating from an older version no longer leaves CallShield unable to open
10+
its database. An August change set up two database indexes the app itself
11+
didn't expect, so on a phone whose data came from a release before August
12+
2026 the database check failed on every launch and the update never
13+
finished. It now completes cleanly.
14+
915
- **Protection data downloads work again.** GitHub moved its certificates to a
1016
new set of Let's Encrypt roots around 2026-08-02. The certificate pins in
1117
v1.7.36 through v1.7.38 matched only the old ones, so every download of the

‎app/src/main/java/com/sysadmindoc/callshield/data/local/AppDatabase.kt‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,21 @@ val MIGRATION_12_13 =
196196
}
197197
}
198198

199-
/** v13 -> v14: retain source evidence and independent feed freshness. */
199+
/**
200+
* v13 -> v14: retain source evidence and independent feed freshness.
201+
*
202+
* Until 2026-09-22 this also created indexes on `evidenceExpiresAt`, which no
203+
* entity declares. Room's post-migration check then failed and rolled back on
204+
* every launch, so no database ever committed them and dropping the two
205+
* statements needs no version bump.
206+
*/
200207
val MIGRATION_13_14 =
201208
object : Migration(DB_VERSION_13, DB_VERSION_14) {
202209
override fun migrate(db: SupportSQLiteDatabase) {
203210
db.execSQL("ALTER TABLE spam_numbers ADD COLUMN evidenceJson TEXT NOT NULL DEFAULT '[]'")
204211
db.execSQL("ALTER TABLE spam_numbers ADD COLUMN evidenceExpiresAt INTEGER")
205212
db.execSQL("ALTER TABLE spam_prefixes ADD COLUMN evidenceJson TEXT NOT NULL DEFAULT '[]'")
206213
db.execSQL("ALTER TABLE spam_prefixes ADD COLUMN evidenceExpiresAt INTEGER")
207-
db.execSQL(
208-
"CREATE INDEX IF NOT EXISTS `index_spam_numbers_evidenceExpiresAt` " +
209-
"ON `spam_numbers`(`evidenceExpiresAt`)",
210-
)
211-
db.execSQL(
212-
"CREATE INDEX IF NOT EXISTS `index_spam_prefixes_evidenceExpiresAt` " +
213-
"ON `spam_prefixes`(`evidenceExpiresAt`)",
214-
)
215214
}
216215
}
217216

0 commit comments

Comments
 (0)