diff --git a/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift b/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift index 22ae36b8db..3631ec2e05 100644 --- a/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift +++ b/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift @@ -539,13 +539,11 @@ extension GRDBMigrator { public class GRDBKeyValueStoreMigrator: GRDBMigrator { public let label: String - private let ydbTransaction: YapDatabaseReadTransaction private let keyStore: SDSKeyValueStore private let finder: LegacyKeyValueFinder init(label: String, keyStore: SDSKeyValueStore, ydbTransaction: YapDatabaseReadTransaction) { self.label = "Migrate \(label)" - self.ydbTransaction = ydbTransaction self.keyStore = keyStore self.finder = LegacyKeyValueFinder(store: keyStore, transaction: ydbTransaction) } @@ -558,7 +556,9 @@ public class GRDBKeyValueStoreMigrator: GRDBMigrator { let count = self.count Logger.info("\(label): \(count)") try Bench(title: label, memorySamplerRatio: memorySamplerRatio(count: count)) { memorySampler in + var recordCount = 0 try finder.enumerateLegacyKeysAndObjects { legacyKey, legacyObject in + recordCount += 1 if let legacyData = legacyObject as? Data { self.finder.store.setData(legacyData, key: legacyKey, transaction: grdbTransaction.asAnyWrite) } else { @@ -566,6 +566,7 @@ public class GRDBKeyValueStoreMigrator: GRDBMigrator { } memorySampler.sample() } + Logger.info("Completed with recordCount: \(recordCount)") } } } @@ -595,7 +596,7 @@ public class GRDBUnorderedRecordMigrator: GRDBMigrator where T: SDSModel { legacyRecord.anyInsert(transaction: grdbTransaction.asAnyWrite) memorySampler.sample() } - Logger.info("completed with recordCount: \(recordCount)") + Logger.info("Completed with recordCount: \(recordCount)") } } } @@ -625,7 +626,7 @@ public class GRDBJobRecordMigrator: GRDBMigrator { legacyRecord.anyInsert(transaction: grdbTransaction.asAnyWrite) memorySampler.sample() } - Logger.info("completed with recordCount: \(recordCount)") + Logger.info("Completed with recordCount: \(recordCount)") } } } @@ -634,12 +635,10 @@ public class GRDBJobRecordMigrator: GRDBMigrator { public class GRDBInteractionMigrator: GRDBMigrator { public let label: String - private let ydbTransaction: YapDatabaseReadTransaction private let finder: LegacyInteractionFinder init(ydbTransaction: YapDatabaseReadTransaction) { self.label = "Migrate Interactions" - self.ydbTransaction = ydbTransaction self.finder = LegacyInteractionFinder(transaction: ydbTransaction) } @@ -652,8 +651,6 @@ public class GRDBInteractionMigrator: GRDBMigrator { Logger.info("\(label): \(count)") try Bench(title: label, memorySamplerRatio: memorySamplerRatio(count: count)) { memorySampler in var recordCount = 0 - let count = TSInteraction.anyCount(transaction: ydbTransaction.asAnyRead) - Logger.info("Interaction count: \(count)") try finder.enumerateInteractions { legacyInteraction in legacyInteraction.anyInsert(transaction: grdbTransaction.asAnyWrite) recordCount += 1 @@ -662,7 +659,7 @@ public class GRDBInteractionMigrator: GRDBMigrator { } memorySampler.sample() } - Logger.info("completed with recordCount: \(recordCount)") + Logger.info("Completed with recordCount: \(recordCount)") } } } @@ -696,7 +693,7 @@ public class GRDBDecryptJobMigrator: GRDBMigrator { } memorySampler.sample() } - Logger.info("completed with recordCount: \(recordCount)") + Logger.info("Completed with recordCount: \(recordCount)") } } } diff --git a/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift b/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift index 6f067f314b..9d4b97ad65 100644 --- a/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift +++ b/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift @@ -59,7 +59,7 @@ public class SDSKeyValueStore: NSObject { ) ) """ - let statement = try database.cachedUpdateStatement(sql: sql) + let statement = try database.makeUpdateStatement(sql: sql) try statement.execute() }