From eeca4019424021ef97384457e43a652d65862a01 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 14 Oct 2024 18:42:55 +0200 Subject: [PATCH] fix: Don't crash if foreign key constraint is invalid in transaction (#1004) ForeignKey constraints can be invalidated in the middle of a transaction even if a later statement in the same transaction will make them valid again. This seems to be causing production crashes. Defer foreign key constraint checks until the end of the transaction to prevent this. --- .../app/pachli/core/database/model/TimelineStatusEntity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/core/database/src/main/kotlin/app/pachli/core/database/model/TimelineStatusEntity.kt b/core/database/src/main/kotlin/app/pachli/core/database/model/TimelineStatusEntity.kt index 7b2e045c7..e942430e2 100644 --- a/core/database/src/main/kotlin/app/pachli/core/database/model/TimelineStatusEntity.kt +++ b/core/database/src/main/kotlin/app/pachli/core/database/model/TimelineStatusEntity.kt @@ -55,6 +55,7 @@ import java.util.Date entity = TimelineAccountEntity::class, parentColumns = ["serverId", "timelineUserId"], childColumns = ["authorServerId", "timelineUserId"], + deferred = true, ), ] ),