You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/sql/README.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,7 +158,26 @@ fn main() {
158
158
159
159
### Applying Migrations
160
160
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
+
importDatabasefrom"@tauri-apps/plugin-sql";
177
+
const db =awaitDatabase.load("sqlite:mydatabase.db");
178
+
```
179
+
180
+
Ensure that the migrations are defined in the correct order and are safe to run multiple times.
0 commit comments