From 2b4d62b086802ece28f1288bd09cbf5f252c45d7 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 May 2018 18:12:32 -0700 Subject: progress on database lookup --- rust/src/database_models.rs | 222 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 rust/src/database_models.rs (limited to 'rust/src/database_models.rs') diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs new file mode 100644 index 00000000..c0118dda --- /dev/null +++ b/rust/src/database_models.rs @@ -0,0 +1,222 @@ + +use uuid::Uuid; +//use diesel::prelude::*; + +use database_schema::*; + +// Ugh. I thought the whole point was to *not* do this, but: +// https://github.com/diesel-rs/diesel/issues/1589 + +/* +table! { + changelog (id) { + id -> Int8, + editgroup_id -> Int8, + timestamp -> Nullable, + } +} +*/ + +#[derive(Debug, Queryable, Identifiable, Associations)] // AsChangeset +#[table_name = "container_edit"] +pub struct ContainerEditRow { + pub id: i64, + pub ident_id: Uuid, + pub rev_id: Option, + pub redirect_id: Option, + pub editgroup_id: i64, + //pub extra_json: Option, +} + +#[derive(Debug, Queryable, Identifiable, Associations)] // AsChangeset +#[table_name = "container_ident"] +pub struct ContainerIdentRow { + pub id: Uuid, + pub is_live: bool, + pub rev_id: Option, + pub redirect_id: Option, +} + +#[derive(Debug, Queryable, Identifiable, Associations)] // AsChangeset +#[table_name = "container_rev"] +pub struct ContainerRevRow { + pub id: i64, + //extra_json: Option, + pub name: Option, + pub parent_ident_id: Option, + pub publisher: Option, + pub issn: Option, +} + +/* +table! { + creator_edit (id) { + id -> Int8, + extra_json -> Nullable, + ident_id -> Uuid, + rev_id -> Nullable, + redirect_id -> Nullable, + editgroup_id -> Int8, + } +} + +table! { + creator_ident (id) { + id -> Uuid, + is_live -> Bool, + rev_id -> Nullable, + redirect_id -> Nullable, + } +} + +table! { + creator_rev (id) { + id -> Int8, + extra_json -> Nullable, + name -> Nullable, + orcid -> Nullable, + } +} + +table! { + editgroup (id) { + id -> Int8, + extra_json -> Nullable, + editor_id -> Int8, + description -> Nullable, + } +} + +table! { + editor (id) { + id -> Int8, + username -> Text, + is_admin -> Bool, + active_editgroup_id -> Nullable, + } +} + +table! { + file_edit (id) { + id -> Int8, + extra_json -> Nullable, + ident_id -> Uuid, + rev_id -> Nullable, + redirect_id -> Nullable, + editgroup_id -> Int8, + } +} + +table! { + file_ident (id) { + id -> Uuid, + is_live -> Bool, + rev_id -> Nullable, + redirect_id -> Nullable, + } +} + +table! { + file_release (id) { + id -> Int8, + file_rev -> Int8, + target_release_ident_id -> Uuid, + } +} + +table! { + file_rev (id) { + id -> Int8, + extra_json -> Nullable, + size -> Nullable, + sha1 -> Nullable, + url -> Nullable, + } +} + +table! { + release_contrib (id) { + id -> Int8, + release_rev -> Int8, + creator_ident_id -> Nullable, + stub -> Nullable, + contrib_type -> Nullable, + } +} + +table! { + release_edit (id) { + id -> Int8, + extra_json -> Nullable, + ident_id -> Uuid, + rev_id -> Nullable, + redirect_id -> Nullable, + editgroup_id -> Int8, + } +} + +table! { + release_ident (id) { + id -> Uuid, + is_live -> Bool, + rev_id -> Nullable, + redirect_id -> Nullable, + } +} + +table! { + release_ref (id) { + id -> Int8, + release_rev -> Int8, + target_release_ident_id -> Nullable, + index -> Nullable, + stub -> Nullable, + } +} + +table! { + release_rev (id) { + id -> Int8, + extra_json -> Nullable, + work_ident_id -> Nullable, + container_ident_id -> Nullable, + title -> Nullable, + license -> Nullable, + release_type -> Nullable, + date -> Nullable, + doi -> Nullable, + volume -> Nullable, + pages -> Nullable, + issue -> Nullable, + } +} + +table! { + work_edit (id) { + id -> Int8, + extra_json -> Nullable, + ident_id -> Uuid, + rev_id -> Nullable, + redirect_id -> Nullable, + editgroup_id -> Int8, + } +} + +table! { + work_ident (id) { + id -> Uuid, + is_live -> Bool, + rev_id -> Nullable, + redirect_id -> Nullable, + } +} + +table! { + work_rev (id) { + id -> Int8, + extra_json -> Nullable, + work_type -> Nullable, + primary_release_id -> Nullable, + } +} +*/ -- cgit v1.2.3