From 8cf2cef05009e4b19d0b5beef2c885e66bac99c1 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 21 Apr 2023 16:37:29 +1000 Subject: [PATCH] Fixed an issue where a migration could incorrectly hide the 'Note to Self' conversation --- .../Database/Migrations/_013_SessionUtilChanges.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SessionMessagingKit/Database/Migrations/_013_SessionUtilChanges.swift b/SessionMessagingKit/Database/Migrations/_013_SessionUtilChanges.swift index b537933ca..8445948f9 100644 --- a/SessionMessagingKit/Database/Migrations/_013_SessionUtilChanges.swift +++ b/SessionMessagingKit/Database/Migrations/_013_SessionUtilChanges.swift @@ -217,8 +217,10 @@ enum _013_SessionUtilChanges: Migration { /// **Note:** Since migrations are run when running tests creating a random SessionThread will result in unexpected thread /// counts so don't do this when running tests (this logic is the same as in `MainAppContext.isRunningTests` if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] == nil { - try SessionThread - .fetchOrCreate(db, id: userPublicKey, variant: .contact, shouldBeVisible: false) + if (try SessionThread.exists(db, id: userPublicKey)) == false { + try SessionThread + .fetchOrCreate(db, id: userPublicKey, variant: .contact, shouldBeVisible: false) + } } Storage.update(progress: 1, for: self, in: target) // In case this is the last migration