database setup + other stuff not rlly important

This commit is contained in:
2026-06-26 14:50:39 -05:00
parent 96843acfe0
commit dab6b12c89
15 changed files with 291 additions and 7 deletions
+14
View File
@@ -0,0 +1,14 @@
use diesel::prelude::*;
use dotenvy::dotenv;
use std::env;
pub mod models;
pub mod schema;
pub fn establish_connection() -> SqliteConnection {
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
SqliteConnection::establish(&database_url)
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
}
+33
View File
@@ -0,0 +1,33 @@
use diesel::prelude::*;
#[derive(Queryable, Selectable)]
#[diesel(table_name = crate::db::schema::app)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct App {
pub id: String, // uuid
pub name: String,
pub description: Option<String>,
pub address: String,
pub ssh_address: Option<String>, // default to normal address
}
#[derive(Queryable, Selectable)]
#[diesel(table_name = crate::db::schema::blog)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Blog {
pub id: String, // uuid
pub title: String,
pub content: String,
pub reference: Option<String>, // uuid
}
#[derive(Queryable, Selectable)]
#[diesel(table_name = crate::db::schema::identities)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Identity {
pub id: String, // uuid
pub common_name: String,
pub username: String,
pub public_key: String,
pub private_key: String,
}
+34
View File
@@ -0,0 +1,34 @@
// @generated automatically by Diesel CLI.
diesel::table! {
app (id) {
id -> Text,
name -> Text,
description -> Nullable<Text>,
address -> Text,
ssh_address -> Nullable<Text>,
}
}
diesel::table! {
blog (id) {
id -> Text,
title -> Text,
content -> Text,
reference -> Nullable<Text>,
}
}
diesel::table! {
identities (id) {
id -> Text,
common_name -> Text,
username -> Text,
public_key -> Text,
private_key -> Text,
}
}
diesel::joinable!(blog -> app (reference));
diesel::allow_tables_to_appear_in_same_query!(app, blog, identities,);
+2
View File
@@ -1,3 +1,5 @@
mod db;
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {