mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Update migration guide
This commit is contained in:
1 parent
d74c5264d3
commit
fd21f97007
1 file changed
+30
@@ -5,6 +5,7 @@ Migrating From GRDB 4 to GRDB 5
|
||||
|
||||
- [Preparing the Migration to GRDB 5](#preparing-the-migration-to-grdb-5)
|
||||
- [New requirements](#new-requirements)
|
||||
- [Database Configuration](#database-configuration)
|
||||
- [ValueObservation](#valueobservation)
|
||||
- [Combine Integration](#combine-integration)
|
||||
- [Other Changes](#other-changes)
|
||||
@@ -31,6 +32,35 @@ GRDB requirements have been bumped:
|
||||
- watchOS 2.0+ (unchanged)
|
||||
|
||||
|
||||
## Database Configuration
|
||||
|
||||
The way to configure a database relies much more on the `Configuration.prepareDatabase(_:)` method:
|
||||
|
||||
```swift
|
||||
// BEFORE: GRDB 4
|
||||
var config = Configuration()
|
||||
config.trace = { ... } // Tracing SQL statements
|
||||
config.prepareDatabase = { db in // prepareDatabase was a property
|
||||
... // Custom setup
|
||||
}
|
||||
let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
|
||||
dbQueue.add(function: ...) // Custom SQL function
|
||||
dbQueue.add(collation: ...) // Custom collation
|
||||
dbQueue.add(tokenizer: ...) // Custom FTS5 tokenizer
|
||||
|
||||
// NEW: GRDB 5
|
||||
var config = Configuration()
|
||||
config.prepareDatabase { db in // prepareDatabase is now a method
|
||||
db.trace { ... }
|
||||
db.add(function: ...)
|
||||
db.add(collation: ...)
|
||||
db.add(tokenizer: ...)
|
||||
...
|
||||
}
|
||||
let dbQueue = try DatabaseQueue(dbPath, configuration: config)
|
||||
```
|
||||
|
||||
|
||||
## ValueObservation
|
||||
|
||||
[ValueObservation] is the database observation tool that tracks changes in database values. It has quite changed in GRDB 5.
|
||||
|
||||
Reference in new issue
Block a user