Fix foreign key constraint issues with backup restore.

This commit is contained in:
Greyson Parrelli
2023-04-25 15:52:09 -04:00
committed by GitHub
parent 0e631508b2
commit a01fb7ff1c
7 changed files with 104 additions and 27 deletions

View File

@@ -218,7 +218,11 @@ object V185_MessageRecipientsAndEditMessageMigration : SignalDatabaseMigration {
}
stopwatch.split("recreate-dependents")
db.execSQL("PRAGMA foreign_key_check")
val foreignKeyViolations: List<SqlUtil.ForeignKeyViolation> = SqlUtil.getForeignKeyViolations(db, "message")
if (foreignKeyViolations.isNotEmpty()) {
Log.w(TAG, "Foreign key violations!\n${foreignKeyViolations.joinToString(separator = "\n")}")
throw IllegalStateException("Foreign key violations!")
}
stopwatch.split("fk-check")
stopwatch.stop(TAG)