Compare commits
2 Commits
7d7815a4bd
...
094ec0aa09
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
094ec0aa09 | ||
|
|
3252d45409 |
@@ -1,9 +0,0 @@
|
||||
-- migrate:up
|
||||
CREATE TABLE PathNode (
|
||||
id integer primary key,
|
||||
title text,
|
||||
description text
|
||||
);
|
||||
|
||||
-- migrate:down
|
||||
-- DROP TABLE PathNode;
|
||||
2
src-tauri/migrations/0001_path_table.down.sql
Normal file
2
src-tauri/migrations/0001_path_table.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE pathVersions;
|
||||
DROP TABLE path;
|
||||
12
src-tauri/migrations/0001_path_table.up.sql
Normal file
12
src-tauri/migrations/0001_path_table.up.sql
Normal 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)
|
||||
);
|
||||
@@ -1,9 +0,0 @@
|
||||
-- migrate:up
|
||||
create table NodeExercise (
|
||||
id integer primary key,
|
||||
ex_type text,
|
||||
content text
|
||||
);
|
||||
|
||||
-- migrate:down
|
||||
-- DROP TABLE NodeExercise;
|
||||
1
src-tauri/migrations/0002_node_table.down.sql
Normal file
1
src-tauri/migrations/0002_node_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE node;
|
||||
6
src-tauri/migrations/0002_node_table.up.sql
Normal file
6
src-tauri/migrations/0002_node_table.up.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE node (
|
||||
id integer primary key,
|
||||
title text,
|
||||
description text,
|
||||
pathId integer references path(id)
|
||||
);
|
||||
1
src-tauri/migrations/0003_exercise_table.down.sql
Normal file
1
src-tauri/migrations/0003_exercise_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE exercise;
|
||||
6
src-tauri/migrations/0003_exercise_table.up.sql
Normal file
6
src-tauri/migrations/0003_exercise_table.up.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
create table exercise (
|
||||
id integer primary key,
|
||||
ex_type text,
|
||||
content text,
|
||||
nodeId integer references node(id)
|
||||
);
|
||||
@@ -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)
|
||||
|
||||
0
src-tauri/src/repositories/mod.rs
Normal file
0
src-tauri/src/repositories/mod.rs
Normal file
11
src-tauri/src/repositories/path_repository.rs
Normal file
11
src-tauri/src/repositories/path_repository.rs
Normal 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>{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user