Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## 1.0.0-BETA29 (unreleased)

* Fix potential race condition between jobs in `connect()` and `disconnect()`.
* [iOS] Fixed issue where automatic driver migrations would fail with the error:
```
Sqlite operation failure database is locked attempted to run migration and failed. closing connection
```

## 1.0.0-BETA28

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.powersync

import app.cash.sqldelight.db.QueryResult
import co.touchlab.sqliter.DatabaseConfiguration
import co.touchlab.sqliter.DatabaseConfiguration.Logging
import co.touchlab.sqliter.DatabaseConnection
import co.touchlab.sqliter.NO_VERSION_CHECK
import co.touchlab.sqliter.interop.Logger
import co.touchlab.sqliter.interop.SqliteErrorType
import co.touchlab.sqliter.sqlite3.sqlite3_commit_hook
Expand Down Expand Up @@ -68,7 +70,13 @@ public actual class DatabaseDriverFactory {
configuration =
DatabaseConfiguration(
name = dbFilename,
version = schema.version.toInt(),
version =
if (!readOnly) {
schema.version.toInt()
} else {
// Don't do migrations on read only connections
NO_VERSION_CHECK
},
create = { connection ->
wrapConnection(connection) {
schema.create(
Expand Down Expand Up @@ -106,6 +114,15 @@ public actual class DatabaseDriverFactory {
driver.execute("PRAGMA query_only=true")
}

// Ensure internal read pool has created a connection at this point. This makes connection
// initialization a bit more deterministic.
driver.executeQuery(
identifier = null,
sql = "SELECT 1",
mapper = { QueryResult.Value(it.getLong(0)) },
parameters = 0,
)

deferredDriver.setDriver(driver)

return driver
Expand Down
Loading