Skip to content

Commit 490d420

Browse files
authored
docs(sql): add preload config example for migrations (#1557)
* docs(sql): add `preload` config example for migrations * improve idempotency explanation
1 parent 1adf7e3 commit 490d420

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

plugins/sql/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,26 @@ fn main() {
158158

159159
### Applying Migrations
160160

161-
Migrations are applied automatically when the plugin is initialized. The plugin runs these migrations against the database specified by the connection string. Ensure that the migrations are defined in the correct order and are idempotent (safe to run multiple times).
161+
To apply the migrations when the plugin is initialized, add the connection string to the `tauri.conf.json` file:
162+
163+
```json
164+
{
165+
"plugins": {
166+
"sql": {
167+
"preload": ["sqlite:mydatabase.db"]
168+
}
169+
}
170+
}
171+
```
172+
173+
Alternatively, the client side `load()` also runs the migrations for a given connection string:
174+
175+
```ts
176+
import Database from "@tauri-apps/plugin-sql";
177+
const db = await Database.load("sqlite:mydatabase.db");
178+
```
179+
180+
Ensure that the migrations are defined in the correct order and are safe to run multiple times.
162181

163182
### Migration Management
164183

0 commit comments

Comments
 (0)