Fix migration crash for unregistered users.

This commit is contained in:
Greyson Parrelli
2023-04-24 10:14:43 -04:00
parent 03ef778dee
commit a11c34d1f6

View File

@@ -43,8 +43,8 @@ object V185_MessageRecipientsAndEditMessageMigration : SignalDatabaseMigration {
val selfId: RecipientId? = getSelfId(db) val selfId: RecipientId? = getSelfId(db)
if (selfId == null) { if (selfId == null) {
val messageCount = db.rawQuery("SELECT COUNT(*) FROM message").readToSingleInt() val outgoingMessageCount = db.rawQuery("SELECT COUNT(*) FROM message WHERE $outgoingClause").readToSingleInt()
if (messageCount == 0) { if (outgoingMessageCount == 0) {
Log.i(TAG, "Could not find ourselves in the DB! Assuming this is an install that hasn't been registered yet.") Log.i(TAG, "Could not find ourselves in the DB! Assuming this is an install that hasn't been registered yet.")
} else { } else {
throw IllegalStateException("Could not find ourselves in the recipient table, but messages exist in the message table!") throw IllegalStateException("Could not find ourselves in the recipient table, but messages exist in the message table!")