@@ -17,7 +17,7 @@ pooling, write serialization, and proper resource management.
1717 * ** Optimized Connection Pooling** : Separate read and write pools for concurrent reads,
1818 even while writing
1919 * ** Write Serialization** : Exclusive write access through connection manager
20- * ** Migration Support** : Uses SQLx's database migration system (runs during preload)
20+ * ** Migration Support** : Uses SQLx's database migration system
2121 * ** Custom Configuration** : Configure read pool size and idle timeouts
2222 * ** Type Safety** : Full TypeScript bindings
2323 * ** Resource Management** : Proper cleanup on application exit
@@ -332,7 +332,7 @@ console.log(`Transfer ID: ${results[2].lastInsertId}`);
332332
333333** How it works:**
334334
335- * Automatically executes ` BEGIN ` before running statements
335+ * Automatically executes ` BEGIN IMMEDIATE ` before running statements
336336 * Executes all statements in order
337337 * Commits with ` COMMIT ` if all statements succeed
338338 * Rolls back with ` ROLLBACK ` if any statement fails
@@ -360,85 +360,8 @@ await db.remove()
360360
361361## Migrations
362362
363- Migrations run automatically during database preload at application startup.
364-
365- ### Setting Up Migrations
366-
367- ` src-tauri/src/lib.rs `
368-
369- ``` rust
370- use tauri_plugin_sqlite :: {Builder , Migration , MigrationKind };
371-
372- fn main () {
373- let migrations = vec! [
374- // Version 1: Create initial schema
375- Migration {
376- version : 1 ,
377- description : " create_users_table" ,
378- sql : vec! [" CREATE TABLE users (
379- id INTEGER PRIMARY KEY AUTOINCREMENT,
380- name TEXT NOT NULL,
381- email TEXT NOT NULL UNIQUE,
382- created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
383- )" ],
384- kind : MigrationKind :: Up ,
385- },
386- // Version 2: Add new column
387- Migration {
388- version : 2 ,
389- description : " add_users_role" ,
390- sql : vec! [" ALTER TABLE users ADD COLUMN role TEXT DEFAULT 'user'" ],
391- kind : MigrationKind :: Up ,
392- },
393- // Version 3: Create index and add trigger (multiple statements)
394- Migration {
395- version : 3 ,
396- description : " create_email_index_and_trigger" ,
397- sql : vec! [
398- " CREATE INDEX idx_users_email ON users(email)" ,
399- " CREATE TRIGGER update_timestamp AFTER UPDATE ON users
400- BEGIN
401- UPDATE users SET created_at = strftime('%s', 'now') WHERE id = NEW.id;
402- END" ,
403- ],
404- kind : MigrationKind :: Up ,
405- },
406- ];
407-
408- tauri :: Builder :: default ()
409- . plugin (
410- Builder :: new ()
411- . add_migrations (" mydb.db" , migrations )
412- . build (),
413- )
414- . run (tauri :: generate_context! ())
415- . expect (" error while running tauri application" );
416- }
417- ```
418-
419- ### Preloading Databases
420-
421- Add databases to ` tauri.conf.json ` to connect and run migrations at startup:
422-
423- ``` json
424- {
425- "plugins" : {
426- "sqlite" : {
427- "preload" : [" mydb.db" , " cache.db" ]
428- }
429- }
430- }
431- ```
432-
433- When preloaded:
434-
435- 1 . The plugin connects to each database
436- 2 . Runs any pending migrations defined in ` add_migrations() `
437- 3 . Keeps the connection open and ready for use
438-
439- > ** Important:** Migrations only run during preload. If you load a database
440- > dynamically with ` Database.load() ` , migrations will not run unless it was
441- > preloaded.
363+ > ** Note:** Database migration support is a planned feature and will be added in a
364+ > future release. It will be based on SQLx's migration framework.
442365
443366## Query Parameter Binding
444367
@@ -526,7 +449,7 @@ const db = Database.get('mydb.db')
526449// Connection happens on first query
527450```
528451
529- ##### ` Database.closeAll(): Promise<boolean > `
452+ ##### ` Database.closeAll(): Promise<void > `
530453
531454Close all database connections.
532455
@@ -578,13 +501,14 @@ if (user) {
578501
579502##### ` close(): Promise<boolean> `
580503
581- Close this database connection.
504+ Close this database connection. Returns ` true ` if the database was loaded and closed,
505+ ` false ` if it wasn't loaded.
582506
583507``` typescript
584508await db .close ()
585509```
586510
587- ##### ` remove(): Promise<boolean > `
511+ ##### ` remove(): Promise<void > `
588512
589513Close the connection and permanently delete database file(s).
590514
0 commit comments