metis_core/dal/database/
models.rs1use diesel::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(
5 Queryable,
6 Selectable,
7 Insertable,
8 AsChangeset,
9 QueryableByName,
10 Debug,
11 Clone,
12 Serialize,
13 Deserialize,
14)]
15#[diesel(table_name = crate::dal::database::schema::documents)]
16#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
17pub struct Document {
18 pub filepath: String,
19 pub id: String,
20 pub title: String,
21 pub document_type: String,
22 pub created_at: f64,
23 pub updated_at: f64,
24 pub archived: bool,
25 pub exit_criteria_met: bool,
26 pub file_hash: String,
27 pub frontmatter_json: String,
28 pub content: Option<String>,
29 pub phase: String,
30 pub strategy_id: Option<String>,
31 pub initiative_id: Option<String>,
32}
33
34#[derive(Queryable, Selectable, Insertable, Debug, Clone, Serialize, Deserialize)]
35#[diesel(table_name = crate::dal::database::schema::document_relationships)]
36#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
37pub struct DocumentRelationship {
38 pub child_id: String,
39 pub parent_id: String,
40 pub child_filepath: String,
41 pub parent_filepath: String,
42}
43
44#[derive(Queryable, Selectable, Insertable, Debug, Clone, Serialize, Deserialize)]
45#[diesel(table_name = crate::dal::database::schema::document_tags)]
46#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
47pub struct DocumentTag {
48 pub document_filepath: String,
49 pub tag: String,
50}
51
52#[derive(Insertable)]
54#[diesel(table_name = crate::dal::database::schema::documents)]
55pub struct NewDocument {
56 pub filepath: String,
57 pub id: String,
58 pub title: String,
59 pub document_type: String,
60 pub created_at: f64,
61 pub updated_at: f64,
62 pub archived: bool,
63 pub exit_criteria_met: bool,
64 pub file_hash: String,
65 pub frontmatter_json: String,
66 pub content: Option<String>,
67 pub phase: String,
68 pub strategy_id: Option<String>,
69 pub initiative_id: Option<String>,
70}
71
72#[derive(Queryable, Selectable, Debug, Clone, Serialize, Deserialize)]
74#[diesel(table_name = crate::dal::database::schema::document_search)]
75#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
76pub struct DocumentSearch {
77 pub rowid: i32,
78 pub document_filepath: String,
79 pub content: Option<String>,
80 pub title: Option<String>,
81 pub document_type: Option<String>,
82}
83
84#[derive(Insertable)]
85#[diesel(table_name = crate::dal::database::schema::document_search)]
86pub struct NewDocumentSearch {
87 pub document_filepath: String,
88 pub content: Option<String>,
89 pub title: Option<String>,
90 pub document_type: Option<String>,
91}
92
93#[derive(
94 Queryable, Selectable, Insertable, AsChangeset, Debug, Clone, Serialize, Deserialize,
95)]
96#[diesel(table_name = crate::dal::database::schema::configuration)]
97#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
98pub struct Configuration {
99 pub key: String,
100 pub value: String,
101 pub updated_at: f64,
102}