Started work on database

This commit is contained in:
Iaphetes 2025-02-06 07:17:02 +01:00
parent db031bc8a8
commit c14cd954a2
7 changed files with 687 additions and 6 deletions

18
src-tauri/src/database.rs Normal file
View file

@ -0,0 +1,18 @@
use sqlx::{migrate::MigrateDatabase, Sqlite};
#[tauri::command]
pub async fn initialize_database(basepath: String) {
let db_url: &str = &format!("sqlite://{}/sqlite.db", basepath);
if !Sqlite::database_exists(db_url).await.unwrap_or(false) {
println!("Creating database {}", db_url);
match Sqlite::create_database(db_url).await {
Ok(_) => println!("Create db success"),
Err(error) => panic!("error: {}", error),
}
} else {
println!("Database already exists");
}
}
#[tauri::command]
async fn store_diff(diff: String) {}