UPDATE: Scratch this topic because simply restarting fixed the issue. But does anyone know if the SQLite-kit
support WAL2?
Hi everyone.
I am sending a pragma
command to the SQLite after booting the server, but when I manually check the value I changed with an SQL IDE, I see the default value, not the updated one.
Here is the snipped of configure
method where I do it:
// Fininsh the configuration
try app.boot()
// Configure sqlite db
guard let sql = app.db as? SQLDatabase else { fatalError("Could not open main sqlite db") }
try await sql.raw("PRAGMA journal_mode = wal2").run()
Does anyone know what I am doing wrong?
Thanks!
Edit: I am likely misunderstanding something because:
// register routes
try routes(app)
// Finish the configuration
try app.boot()
// Configure sqlite db
guard let sql = app.db as? SQLDatabase else { fatalError("Could not open main sqlite db") }
let a = (try await sql.raw("pragma synchronous").first(decoding: SynchronousStatus.self)?.synchronous).flatMap(String.init) ?? "--"
let b = try await sql.raw("pragma journal_mode").first(decoding: JournalModeStatus.self)?.journal_mode ?? "--"
try await sql.raw("pragma journal_mode = wal").run()
try await sql.raw("pragma synchronous = normal").run()
let c = (try await sql.raw("pragma synchronous").first(decoding: SynchronousStatus.self)?.synchronous).flatMap(String.init) ?? "--"
let d = try await sql.raw("pragma journal_mode").first(decoding: JournalModeStatus.self)?.journal_mode ?? "--"
app.logger.info("[Before] syncronous = \(a), journal_mode = \(b).")
app.logger.info("[After] syncronous = \(c), journal_mode = \(d).")
results in:
[ DEBUG ] pragma synchronous [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[ DEBUG ] pragma journal_mode [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[ DEBUG ] pragma journal_mode = wal [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[ DEBUG ] pragma synchronous = normal [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[ DEBUG ] pragma synchronous [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[ DEBUG ] pragma journal_mode [] [database-id: sqlite] (SQLiteNIO/SQLiteConnection.swift:194)
[ INFO ] [Before] syncronous = 2, journal_mode = delete. (App/configure.swift:226)
[ INFO ] [After] syncronous = 1, journal_mode = wal. (App/configure.swift:227)
Edit2: After restarting my SQL editor, it started displaying the correct pragma
values.