File tree 2 files changed +22
-1
lines changed
core/src/iosMain/kotlin/com/powersync
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 3
3
## 1.0.0-BETA29 (unreleased)
4
4
5
5
* 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
+ ```
6
10
7
11
## 1.0.0-BETA28
8
12
Original file line number Diff line number Diff line change 1
1
package com.powersync
2
2
3
+ import app.cash.sqldelight.db.QueryResult
3
4
import co.touchlab.sqliter.DatabaseConfiguration
4
5
import co.touchlab.sqliter.DatabaseConfiguration.Logging
5
6
import co.touchlab.sqliter.DatabaseConnection
7
+ import co.touchlab.sqliter.NO_VERSION_CHECK
6
8
import co.touchlab.sqliter.interop.Logger
7
9
import co.touchlab.sqliter.interop.SqliteErrorType
8
10
import co.touchlab.sqliter.sqlite3.sqlite3_commit_hook
@@ -68,7 +70,13 @@ public actual class DatabaseDriverFactory {
68
70
configuration =
69
71
DatabaseConfiguration (
70
72
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
+ },
72
80
create = { connection ->
73
81
wrapConnection(connection) {
74
82
schema.create(
@@ -106,6 +114,15 @@ public actual class DatabaseDriverFactory {
106
114
driver.execute(" PRAGMA query_only=true" )
107
115
}
108
116
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
+
109
126
deferredDriver.setDriver(driver)
110
127
111
128
return driver
You can’t perform that action at this time.
0 commit comments