Skip to content

Commit 25a3a18

Browse files
committed
Add everything inside the same block
1 parent cd929ab commit 25a3a18

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

Modules/DataModel/Sources/PocketCastsDataModel/Private/Managers/Util/DatabaseHelper.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@ import PocketCastsUtils
44

55
class DatabaseHelper {
66
class func setup(queue: PCDBQueue) {
7-
var startingSchemaVersion: Int32 = 0
8-
9-
queue.read { db in
7+
queue.write { db in
108
do {
119
try db.executeQuery("PRAGMA busy_timeout = 10000", values: nil).close()
1210

13-
let rs = try db.executeQuery("PRAGMA user_version", values: nil)
14-
if rs.next() { startingSchemaVersion = rs.int(forColumnIndex: 0) }
15-
rs.close()
16-
} catch {
17-
FileLog.shared.addMessage("Failed to setup database \(db.lastErrorCode()): \(db.lastErrorMessage()) actual error: \(error)")
18-
}
19-
}
11+
let startingSchemaVersion = db.pragmaUserVersion() ?? 0
2012

21-
queue.write { db in
22-
do {
2313
var newSchemaVersion = startingSchemaVersion
2414
upgradeIfRequired(schemaVersion: &newSchemaVersion, db: db)
2515

0 commit comments

Comments
 (0)