replaced tauri-sql with prisma-client-rust

This commit is contained in:
Ren Amamiya 2023-04-02 08:30:36 +07:00
parent 27082acf5c
commit 9b8a96c651
8 changed files with 2117 additions and 331 deletions

View File

@ -0,0 +1,2 @@
[alias]
prisma = "run --bin prisma --"

View File

@ -2,3 +2,5 @@
# will have compiled files and executables
/target/
# prisma
src/prisma.rs

2406
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,11 +17,10 @@ tauri-build = { version = "1.2", features = [] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["clipboard-read-text", "clipboard-write-text", "http-request", "os-all", "shell-open", "system-tray", "window-close", "window-start-dragging"] }
[dependencies.tauri-plugin-sql]
git = "https://github.com/tauri-apps/plugins-workspace"
branch = "dev"
features = ["sqlite"]
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.7", default-features = false, features = ["sqlite", "migrations", "mocking", "specta"] }
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.7", default-features = false, features = ["sqlite", "migrations", "mocking", "specta"] }
specta = "1.0.0"
tauri-specta = { version = "1.0.0", features = ["typescript"] }
[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2.7"

View File

View File

@ -0,0 +1,11 @@
datasource db {
provider = "sqlite"
url = "file:lume.db"
}
generator client {
// Corresponds to the cargo alias created earlier
provider = "cargo prisma"
// The location to generate the client. Is relative to the position of the schema
output = "../src/prisma.rs"
}

View File

@ -0,0 +1,3 @@
fn main() {
prisma_client_rust_cli::run();
}

View File

@ -8,7 +8,6 @@
extern crate objc;
use tauri::{Manager, WindowEvent};
use tauri_plugin_sql::{Migration, MigrationKind};
#[cfg(target_os = "macos")]
use window_ext::WindowExt;
@ -25,23 +24,11 @@ fn main() {
Ok(())
})
.plugin(
tauri_plugin_sql::Builder::default()
.add_migrations(
"sqlite:lume.db",
vec![Migration {
version: 1,
description: "create default tables",
sql: include_str!("../migrations/20230226004139_create_tables.sql"),
kind: MigrationKind::Up,
}],
)
.build(),
)
.on_window_event(|e| {
#[cfg(target_os = "macos")]
let apply_offset = || {
let win = e.window();
// keep inset for traffic lights when window resize (macos)
win.position_traffic_lights(8.0, 20.0);
};
#[cfg(target_os = "macos")]