Skip to content

Commit 4b62aad

Browse files
situ2001FabianLars
andauthored
add another way to add migrations for sql plugin (#3391)
Co-authored-by: Fabian-Lars <[email protected]>
1 parent 88ee1ef commit 4b62aad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/content/docs/plugin/sql.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,19 @@ let migration = Migration {
220220
};
221221
````
222222
223+
Or if you want to use SQL from a file, you can include it by using `include_str!`:
224+
225+
```rust
226+
use tauri_plugin_sql::{Migration, MigrationKind};
227+
228+
let migration = Migration {
229+
version: 1,
230+
description: "create_initial_tables",
231+
sql: include_str!("../drizzle/0000_graceful_boomer.sql"),
232+
kind: MigrationKind::Up,
233+
};
234+
```
235+
223236
### Adding Migrations to the Plugin Builder
224237
225238
Migrations are registered with the [`Builder`](https://docs.rs/tauri-plugin-sql/latest/tauri_plugin_sql/struct.Builder.html) struct provided by the plugin. Use the `add_migrations` method to add your migrations to the plugin for a specific database connection.

0 commit comments

Comments
 (0)