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)
if (selfId == null) {
val messageCount = db.rawQuery("SELECT COUNT(*) FROM message").readToSingleInt()
if (messageCount == 0) {
val outgoingMessageCount = db.rawQuery("SELECT COUNT(*) FROM message WHERE $outgoingClause").readToSingleInt()
if (outgoingMessageCount == 0) {
Log.i(TAG, "Could not find ourselves in the DB! Assuming this is an install that hasn't been registered yet.")
} else {
throw IllegalStateException("Could not find ourselves in the recipient table, but messages exist in the message table!")