Compare commits

...

2 Commits

Author SHA1 Message Date
Nico
094ec0aa09 begin implementing repository for accessing database 2025-09-17 21:54:01 +02:00
Nico
3252d45409 update migrations 2025-09-17 21:53:27 +02:00
12 changed files with 41 additions and 18 deletions

View File

@@ -1,9 +0,0 @@
-- migrate:up
CREATE TABLE PathNode (
id integer primary key,
title text,
description text
);
-- migrate:down
-- DROP TABLE PathNode;

View File

@@ -0,0 +1,2 @@
DROP TABLE pathVersions;
DROP TABLE path;

View File

@@ -0,0 +1,12 @@
CREATE TABLE path (
id integer primary key,
title text,
description text,
versions text
);
CREATE TABLE pathVersions (
pathId integer references path(id),
versionNumber string,
primary key (pathId, versionNumber)
);

View File

@@ -1,9 +0,0 @@
-- migrate:up
create table NodeExercise (
id integer primary key,
ex_type text,
content text
);
-- migrate:down
-- DROP TABLE NodeExercise;

View File

@@ -0,0 +1 @@
DROP TABLE node;

View File

@@ -0,0 +1,6 @@
CREATE TABLE node (
id integer primary key,
title text,
description text,
pathId integer references path(id)
);

View File

@@ -0,0 +1 @@
DROP TABLE exercise;

View File

@@ -0,0 +1,6 @@
create table exercise (
id integer primary key,
ex_type text,
content text,
nodeId integer references node(id)
);

View File

@@ -27,7 +27,9 @@ async fn db_version(app_handle: tauri::AppHandle) -> Result<String, String> {
.await
.map_err(|e| e.to_string())?;
sqlx::migrate!("./migrations").run(&pool).await.map_err(|e| e.to_string())?;
let row: (String,) = sqlx::query_as("SELECT sqlite_version()")
.fetch_one(&pool)

View File

View File

@@ -0,0 +1,11 @@
use sqlx::sqlite::{SqlitePool};
pub struct PathRepository<'a> {
pub pool: &'a SqlitePool,
}
impl<'a> PathRepository<'a> {
pub fn get_path_by_id(&self, id: i32) -> Result<Path>{
}
}