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 pub short_code: String,
33}
34
35#[derive(Queryable, Selectable, Insertable, Debug, Clone, Serialize, Deserialize)]
36#[diesel(table_name = crate::dal::database::schema::document_relationships)]
37#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
38pub struct DocumentRelationship {
39 pub child_id: String,
40 pub parent_id: String,
41 pub child_filepath: String,
42 pub parent_filepath: String,
43}
44
45#[derive(Queryable, Selectable, Insertable, Debug, Clone, Serialize, Deserialize)]
46#[diesel(table_name = crate::dal::database::schema::document_tags)]
47#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
48pub struct DocumentTag {
49 pub document_filepath: String,
50 pub tag: String,
51}
52
53#[derive(Insertable)]
55#[diesel(table_name = crate::dal::database::schema::documents)]
56pub struct NewDocument {
57 pub filepath: String,
58 pub id: String,
59 pub title: String,
60 pub document_type: String,
61 pub created_at: f64,
62 pub updated_at: f64,
63 pub archived: bool,
64 pub exit_criteria_met: bool,
65 pub file_hash: String,
66 pub frontmatter_json: String,
67 pub content: Option<String>,
68 pub phase: String,
69 pub strategy_id: Option<String>,
70 pub initiative_id: Option<String>,
71 pub short_code: String,
72}
73
74#[derive(Queryable, Selectable, Debug, Clone, Serialize, Deserialize)]
76#[diesel(table_name = crate::dal::database::schema::document_search)]
77#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
78pub struct DocumentSearch {
79 pub rowid: i32,
80 pub document_filepath: String,
81 pub content: Option<String>,
82 pub title: Option<String>,
83 pub document_type: Option<String>,
84}
85
86#[derive(Insertable)]
87#[diesel(table_name = crate::dal::database::schema::document_search)]
88pub struct NewDocumentSearch {
89 pub document_filepath: String,
90 pub content: Option<String>,
91 pub title: Option<String>,
92 pub document_type: Option<String>,
93}
94
95#[derive(Queryable, Selectable, Insertable, AsChangeset, Debug, Clone, Serialize, Deserialize)]
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}