File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
core/src/iosMain/kotlin/com/powersync Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 33## 1.0.0-BETA29 (unreleased)
44
55* Fix potential race condition between jobs in ` connect() ` and ` disconnect() ` .
6+ * [ iOS] Fixed issue where automatic driver migrations would fail with the error:
7+ ```
8+ Sqlite operation failure database is locked attempted to run migration and failed. closing connection
9+ ```
610
711## 1.0.0-BETA28
812
Original file line number Diff line number Diff line change 11package com.powersync
22
3+ import app.cash.sqldelight.db.QueryResult
34import co.touchlab.sqliter.DatabaseConfiguration
45import co.touchlab.sqliter.DatabaseConfiguration.Logging
56import co.touchlab.sqliter.DatabaseConnection
7+ import co.touchlab.sqliter.NO_VERSION_CHECK
68import co.touchlab.sqliter.interop.Logger
79import co.touchlab.sqliter.interop.SqliteErrorType
810import co.touchlab.sqliter.sqlite3.sqlite3_commit_hook
@@ -68,7 +70,13 @@ public actual class DatabaseDriverFactory {
6870 configuration =
6971 DatabaseConfiguration (
7072 name = dbFilename,
71- version = schema.version.toInt(),
73+ version =
74+ if (! readOnly) {
75+ schema.version.toInt()
76+ } else {
77+ // Don't do migrations on read only connections
78+ NO_VERSION_CHECK
79+ },
7280 create = { connection ->
7381 wrapConnection(connection) {
7482 schema.create(
@@ -106,6 +114,15 @@ public actual class DatabaseDriverFactory {
106114 driver.execute(" PRAGMA query_only=true" )
107115 }
108116
117+ // Ensure internal read pool has created a connection at this point. This makes connection
118+ // initialization a bit more deterministic.
119+ driver.executeQuery(
120+ identifier = null ,
121+ sql = " SELECT 1" ,
122+ mapper = { QueryResult .Value (it.getLong(0 )) },
123+ parameters = 0 ,
124+ )
125+
109126 deferredDriver.setDriver(driver)
110127
111128 return driver
You can’t perform that action at this time.
0 commit comments