aboutsummaryrefslogtreecommitdiff
path: root/src/db/models.rs
diff options
context:
space:
mode:
authorNathan Perry <avaglir@gmail.com>2018-04-04 22:09:13 -0400
committerNathan Perry <avaglir@gmail.com>2018-04-04 22:09:13 -0400
commitbf6745af21f82562af0b85de566f4e7b7ef5df8c (patch)
treea7b70656c84b7a9cf1d71a67921b5d171308234b /src/db/models.rs
parent180ef480c0037cfcb5735fdfd2c60f910bf5ba5a (diff)
revamp database structure
Diffstat (limited to 'src/db/models.rs')
-rw-r--r--src/db/models.rs55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/db/models.rs b/src/db/models.rs
index 899fa1e..c06c41e 100644
--- a/src/db/models.rs
+++ b/src/db/models.rs
@@ -1,18 +1,65 @@
use super::schema::*;
+use chrono::naive::NaiveDateTime;
-#[derive(Insertable, Queryable, Identifiable, AsChangeset)]
+#[derive(Insertable, Queryable, Identifiable, AsChangeset, Debug, Associations)]
+#[belongs_to(Audio)]
+#[belongs_to(Image)]
+#[belongs_to(TextMeme)]
+#[belongs_to(ImageMeme)]
+#[belongs_to(TextMeme)]
+#[table_name="metadata"]
+pub struct Metadata {
+ pub id: i32,
+ pub created: NaiveDateTime,
+ pub created_by: i64,
+}
+
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug, Associations)]
+#[belongs_to(AudioMeme)]
+#[belongs_to(TextMeme)]
+#[table_name="audio"]
+pub struct Audio {
+ pub id: i32,
+ pub data: Vec<u8>,
+ pub metadata_id: i32,
+}
+
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug, Associations)]
+#[belongs_to(ImageMeme)]
+#[belongs_to(TextMeme)]
+#[table_name="images"]
+pub struct Image {
+ pub id: i32,
+ pub data: Vec<u8>,
+ pub metadata_id: i32,
+}
+
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
#[table_name="audio_memes"]
pub struct AudioMeme {
pub id: i32,
pub title: String,
- pub link: String,
+ pub audio_id: i32,
+ pub metadata_id: i32,
}
-#[derive(Insertable, Queryable, Identifiable, AsChangeset)]
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
#[table_name="text_memes"]
pub struct TextMeme {
pub id: i32,
pub title: String,
pub content: String,
- pub pic_related: String,
+ pub image_id: Option<i32>,
+ pub audio_id: Option<i32>,
+ pub metadata_id: i32,
+}
+
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug, Associations)]
+#[belongs_to(Metadata)]
+#[table_name="audit_records"]
+pub struct AuditRecord {
+ pub id: i32,
+ pub updated: NaiveDateTime,
+ pub updated_by: i64,
+ pub metadata_id: i32,
}