diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 8cf6560..96c12c1 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -25,18 +25,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -61,12 +49,6 @@ dependencies = [ "alloc-no-stdlib", ] -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "alsa" version = "0.9.1" @@ -424,15 +406,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "atoi" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" -dependencies = [ - "num-traits", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -996,12 +969,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "convert_case" version = "0.4.0" @@ -1154,21 +1121,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" - [[package]] name = "crc32fast" version = "1.5.0" @@ -1187,15 +1139,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "crossbeam-queue" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -1337,7 +1280,6 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ - "const-oid", "pem-rfc7468", "zeroize", ] @@ -1414,9 +1356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", ] [[package]] @@ -1510,12 +1450,6 @@ dependencies = [ "syn 2.0.108", ] -[[package]] -name = "dotenvy" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" - [[package]] name = "downcast-rs" version = "1.2.1" @@ -1563,9 +1497,6 @@ name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -dependencies = [ - "serde", -] [[package]] name = "embed-resource" @@ -1730,17 +1661,6 @@ version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" -[[package]] -name = "etcetera" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" -dependencies = [ - "cfg-if", - "home", - "windows-sys 0.48.0", -] - [[package]] name = "event-listener" version = "5.4.1" @@ -1921,17 +1841,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "flume" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" -dependencies = [ - "futures-core", - "futures-sink", - "spin", -] - [[package]] name = "fnv" version = "1.0.7" @@ -2065,17 +1974,6 @@ dependencies = [ "futures-util", ] -[[package]] -name = "futures-intrusive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" -dependencies = [ - "futures-core", - "lock_api", - "parking_lot", -] - [[package]] name = "futures-io" version = "0.3.31" @@ -2526,6 +2424,7 @@ dependencies = [ "rodio", "rubato", "rusqlite", + "rusqlite_migration", "rustfft", "serde", "serde_json", @@ -2547,7 +2446,6 @@ dependencies = [ "tauri-plugin-os", "tauri-plugin-process", "tauri-plugin-single-instance", - "tauri-plugin-sql", "tauri-plugin-store", "tauri-plugin-updater", "tauri-specta", @@ -2563,16 +2461,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.8", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash 0.8.12", + "ahash", ] [[package]] @@ -2581,8 +2470,6 @@ version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "allocator-api2", - "equivalent", "foldhash", ] @@ -2592,15 +2479,6 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" -[[package]] -name = "hashlink" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" -dependencies = [ - "hashbrown 0.14.5", -] - [[package]] name = "hashlink" version = "0.10.0" @@ -2634,24 +2512,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "home" version = "0.5.12" @@ -3213,9 +3073,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -3273,12 +3130,6 @@ dependencies = [ "windows-link 0.2.1", ] -[[package]] -name = "libm" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" - [[package]] name = "libredox" version = "0.1.10" @@ -3292,9 +3143,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.30.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f" dependencies = [ "cc", "pkg-config", @@ -3418,16 +3269,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest", -] - [[package]] name = "memchr" version = "2.7.6" @@ -3679,23 +3520,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" -dependencies = [ - "byteorder", - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.5", - "smallvec 1.15.1", - "zeroize", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -3731,17 +3555,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.2" @@ -3760,7 +3573,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -4515,27 +4327,6 @@ dependencies = [ "futures-io", ] -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" version = "0.3.32" @@ -5225,26 +5016,6 @@ dependencies = [ "symphonia", ] -[[package]] -name = "rsa" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core 0.6.4", - "signature", - "spki", - "subtle", - "zeroize", -] - [[package]] name = "rubato" version = "0.16.2" @@ -5259,18 +5030,28 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.32.1" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" +checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f" dependencies = [ "bitflags 2.10.0", "fallible-iterator", "fallible-streaming-iterator", - "hashlink 0.9.1", + "hashlink", "libsqlite3-sys", "smallvec 1.15.1", ] +[[package]] +name = "rusqlite_migration" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fc9767ae49274bafd3e55be9d30405a033b7a59548327d87fd4971fbb58e264" +dependencies = [ + "log", + "rusqlite", +] + [[package]] name = "rust-stemmers" version = "1.2.0" @@ -5751,17 +5532,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha2" version = "0.10.9" @@ -5798,16 +5568,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core 0.6.4", -] - [[package]] name = "simd-adler32" version = "0.3.7" @@ -5843,9 +5603,6 @@ name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" -dependencies = [ - "serde", -] [[package]] name = "smallvec" @@ -5966,217 +5723,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "sqlx" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" -dependencies = [ - "sqlx-core", - "sqlx-macros", - "sqlx-mysql", - "sqlx-postgres", - "sqlx-sqlite", -] - -[[package]] -name = "sqlx-core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" -dependencies = [ - "base64 0.22.1", - "bytes", - "crc", - "crossbeam-queue", - "either", - "event-listener", - "futures-core", - "futures-intrusive", - "futures-io", - "futures-util", - "hashbrown 0.15.5", - "hashlink 0.10.0", - "indexmap 2.12.0", - "log", - "memchr", - "once_cell", - "percent-encoding", - "serde", - "serde_json", - "sha2", - "smallvec 1.15.1", - "thiserror 2.0.17", - "time", - "tokio", - "tokio-stream", - "tracing", - "url", -] - -[[package]] -name = "sqlx-macros" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" -dependencies = [ - "proc-macro2", - "quote", - "sqlx-core", - "sqlx-macros-core", - "syn 2.0.108", -] - -[[package]] -name = "sqlx-macros-core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" -dependencies = [ - "dotenvy", - "either", - "heck 0.5.0", - "hex", - "once_cell", - "proc-macro2", - "quote", - "serde", - "serde_json", - "sha2", - "sqlx-core", - "sqlx-mysql", - "sqlx-postgres", - "sqlx-sqlite", - "syn 2.0.108", - "tokio", - "url", -] - -[[package]] -name = "sqlx-mysql" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" -dependencies = [ - "atoi", - "base64 0.22.1", - "bitflags 2.10.0", - "byteorder", - "bytes", - "crc", - "digest", - "dotenvy", - "either", - "futures-channel", - "futures-core", - "futures-io", - "futures-util", - "generic-array", - "hex", - "hkdf", - "hmac", - "itoa", - "log", - "md-5", - "memchr", - "once_cell", - "percent-encoding", - "rand 0.8.5", - "rsa", - "serde", - "sha1", - "sha2", - "smallvec 1.15.1", - "sqlx-core", - "stringprep", - "thiserror 2.0.17", - "time", - "tracing", - "whoami", -] - -[[package]] -name = "sqlx-postgres" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" -dependencies = [ - "atoi", - "base64 0.22.1", - "bitflags 2.10.0", - "byteorder", - "crc", - "dotenvy", - "etcetera", - "futures-channel", - "futures-core", - "futures-util", - "hex", - "hkdf", - "hmac", - "home", - "itoa", - "log", - "md-5", - "memchr", - "once_cell", - "rand 0.8.5", - "serde", - "serde_json", - "sha2", - "smallvec 1.15.1", - "sqlx-core", - "stringprep", - "thiserror 2.0.17", - "time", - "tracing", - "whoami", -] - -[[package]] -name = "sqlx-sqlite" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" -dependencies = [ - "atoi", - "flume", - "futures-channel", - "futures-core", - "futures-executor", - "futures-intrusive", - "futures-util", - "libsqlite3-sys", - "log", - "percent-encoding", - "serde", - "serde_urlencoded", - "sqlx-core", - "thiserror 2.0.17", - "time", - "tracing", - "url", -] - [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -6220,17 +5766,6 @@ dependencies = [ "quote", ] -[[package]] -name = "stringprep" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" -dependencies = [ - "unicode-bidi", - "unicode-normalization", - "unicode-properties", -] - [[package]] name = "strsim" version = "0.11.1" @@ -6893,25 +6428,6 @@ dependencies = [ "zbus", ] -[[package]] -name = "tauri-plugin-sql" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a593f08c357091ba802a388d1161e99f05751278fb7204faeb08520da579a7c" -dependencies = [ - "futures-core", - "indexmap 2.12.0", - "log", - "serde", - "serde_json", - "sqlx", - "tauri", - "tauri-plugin", - "thiserror 2.0.17", - "time", - "tokio", -] - [[package]] name = "tauri-plugin-store" version = "2.4.1" @@ -7450,7 +6966,6 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -7617,33 +7132,12 @@ version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" -[[package]] -name = "unicode-bidi" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" - [[package]] name = "unicode-ident" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-properties" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" - [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -7854,12 +7348,6 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "wasite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" - [[package]] name = "wasm-bindgen" version = "0.2.104" @@ -8196,16 +7684,6 @@ dependencies = [ "fs_extra", ] -[[package]] -name = "whoami" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" -dependencies = [ - "libredox", - "wasite", -] - [[package]] name = "widestring" version = "1.2.1" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c4697a1..4e31a34 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -41,7 +41,7 @@ tauri-plugin-os = "2.3.2" tauri-plugin-clipboard-manager = "2.3.2" tauri-plugin-macos-permissions = "2.3.0" tauri-plugin-process = "2.3.1" -tauri-plugin-sql = { version = "2.3.1", features = ["sqlite"] } +rusqlite_migration = "2.3" tauri-plugin-fs = "2.4.4" serde = { version = "1", features = ["derive"] } serde_json = "1" @@ -63,7 +63,7 @@ rustfft = "6.4.0" strsim = "0.11.0" natural = "0.5.0" chrono = "0.4" -rusqlite = { version = "0.32.1", features = ["bundled"] } +rusqlite = { version = "0.37", features = ["bundled"] } tar = "0.4.44" flate2 = "1.0" transcribe-rs = "0.1.4" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 4a0e002..882c112 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -352,14 +352,6 @@ pub fn run() { .plugin(tauri_plugin_macos_permissions::init()) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_store::Builder::default().build()) - .plugin( - tauri_plugin_sql::Builder::default() - .add_migrations( - "sqlite:history.db", - managers::history::HistoryManager::get_migrations(), - ) - .build(), - ) .plugin(tauri_plugin_global_shortcut::Builder::new().build()) .plugin(tauri_plugin_autostart::init( MacosLauncher::LaunchAgent, diff --git a/src-tauri/src/managers/history.rs b/src-tauri/src/managers/history.rs index a2dcaf8..0a8c7f0 100644 --- a/src-tauri/src/managers/history.rs +++ b/src-tauri/src/managers/history.rs @@ -1,16 +1,38 @@ use anyhow::Result; use chrono::{DateTime, Local, Utc}; -use log::{debug, error}; +use log::{debug, error, info}; use rusqlite::{params, Connection, OptionalExtension}; +use rusqlite_migration::{Migrations, M}; use serde::{Deserialize, Serialize}; use specta::Type; use std::fs; use std::path::PathBuf; use tauri::{AppHandle, Emitter, Manager}; -use tauri_plugin_sql::{Migration, MigrationKind}; use crate::audio_toolkit::save_wav_file; +/// Database migrations for transcription history. +/// Each migration is applied in order. The library tracks which migrations +/// have been applied using SQLite's user_version pragma. +/// +/// Note: For users upgrading from tauri-plugin-sql, migrate_from_tauri_plugin_sql() +/// converts the old _sqlx_migrations table tracking to the user_version pragma, +/// ensuring migrations don't re-run on existing databases. +static MIGRATIONS: &[M] = &[ + M::up( + "CREATE TABLE IF NOT EXISTS transcription_history ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + file_name TEXT NOT NULL, + timestamp INTEGER NOT NULL, + saved BOOLEAN NOT NULL DEFAULT 0, + title TEXT NOT NULL, + transcription_text TEXT NOT NULL + );", + ), + M::up("ALTER TABLE transcription_history ADD COLUMN post_processed_text TEXT;"), + M::up("ALTER TABLE transcription_history ADD COLUMN post_process_prompt TEXT;"), +]; + #[derive(Clone, Debug, Serialize, Deserialize, Type)] pub struct HistoryEntry { pub id: i64, @@ -48,46 +70,105 @@ impl HistoryManager { db_path, }; - // Initialize database + // Initialize database and run migrations synchronously manager.init_database()?; Ok(manager) } - pub fn get_migrations() -> Vec { - vec![ - Migration { - version: 1, - description: "create_transcription_history_table", - sql: "CREATE TABLE IF NOT EXISTS transcription_history ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - file_name TEXT NOT NULL, - timestamp INTEGER NOT NULL, - saved BOOLEAN NOT NULL DEFAULT 0, - title TEXT NOT NULL, - transcription_text TEXT NOT NULL - );", - kind: MigrationKind::Up, - }, - Migration { - version: 2, - description: "add_post_processed_text_column", - sql: "ALTER TABLE transcription_history ADD COLUMN post_processed_text TEXT;", - kind: MigrationKind::Up, - }, - Migration { - version: 3, - description: "add_post_process_prompt_column", - sql: "ALTER TABLE transcription_history ADD COLUMN post_process_prompt TEXT;", - kind: MigrationKind::Up, - }, - ] + fn init_database(&self) -> Result<()> { + info!("Initializing database at {:?}", self.db_path); + + let mut conn = Connection::open(&self.db_path)?; + + // Handle migration from tauri-plugin-sql to rusqlite_migration + // tauri-plugin-sql used _sqlx_migrations table, rusqlite_migration uses user_version pragma + self.migrate_from_tauri_plugin_sql(&conn)?; + + // Create migrations object and run to latest version + let migrations = Migrations::new(MIGRATIONS.to_vec()); + + // Validate migrations in debug builds + #[cfg(debug_assertions)] + migrations.validate().expect("Invalid migrations"); + + // Get current version before migration + let version_before: i32 = + conn.pragma_query_value(None, "user_version", |row| row.get(0))?; + debug!("Database version before migration: {}", version_before); + + // Apply any pending migrations + migrations.to_latest(&mut conn)?; + + // Get version after migration + let version_after: i32 = conn.pragma_query_value(None, "user_version", |row| row.get(0))?; + + if version_after > version_before { + info!( + "Database migrated from version {} to {}", + version_before, version_after + ); + } else { + debug!("Database already at latest version {}", version_after); + } + + Ok(()) } - fn init_database(&self) -> Result<()> { - // Database initialization and migrations are handled by tauri-plugin-sql - // via the preload configuration in tauri.conf.json - debug!("Database path: {:?}", self.db_path); + /// Migrate from tauri-plugin-sql's migration tracking to rusqlite_migration's. + /// tauri-plugin-sql used a _sqlx_migrations table, while rusqlite_migration uses + /// SQLite's user_version pragma. This function checks if the old system was in use + /// and sets the user_version accordingly so migrations don't re-run. + fn migrate_from_tauri_plugin_sql(&self, conn: &Connection) -> Result<()> { + // Check if the old _sqlx_migrations table exists + let has_sqlx_migrations: bool = conn + .query_row( + "SELECT COUNT(*) > 0 FROM sqlite_master WHERE type='table' AND name='_sqlx_migrations'", + [], + |row| row.get(0), + ) + .unwrap_or(false); + + if !has_sqlx_migrations { + return Ok(()); + } + + // Check current user_version + let current_version: i32 = + conn.pragma_query_value(None, "user_version", |row| row.get(0))?; + + if current_version > 0 { + // Already migrated to rusqlite_migration system + return Ok(()); + } + + // Get the highest version from the old migrations table + let old_version: i32 = conn + .query_row( + "SELECT COALESCE(MAX(version), 0) FROM _sqlx_migrations WHERE success = 1", + [], + |row| row.get(0), + ) + .unwrap_or(0); + + if old_version > 0 { + info!( + "Migrating from tauri-plugin-sql (version {}) to rusqlite_migration", + old_version + ); + + // Set user_version to match the old migration state + conn.pragma_update(None, "user_version", old_version)?; + + // Optionally drop the old migrations table (keeping it doesn't hurt) + // conn.execute("DROP TABLE IF EXISTS _sqlx_migrations", [])?; + + info!( + "Migration tracking converted: user_version set to {}", + old_version + ); + } + Ok(()) } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 2ebdee1..53d45bd 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -76,9 +76,6 @@ "endpoints": [ "https://github.com/cjpais/Handy/releases/latest/download/latest.json" ] - }, - "sql": { - "preload": ["sqlite:history.db"] } } }