summaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-24 22:35:37 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-24 22:35:37 -0700
commit2991a4349f86cca8d1dcc978e3506f3032d5ebdd (patch)
tree387d96b7d215115cae5f342525d2ba53e7fe6e74 /rust/src
parentd91c04608480f819263dedc8eaa4ecf707e5914e (diff)
downloadfatcat-2991a4349f86cca8d1dcc978e3506f3032d5ebdd.tar.gz
fatcat-2991a4349f86cca8d1dcc978e3506f3032d5ebdd.zip
extra_json in SQL schema and implementation
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/api_server.rs14
-rw-r--r--rust/src/database_models.rs12
-rw-r--r--rust/src/database_schema.rs10
3 files changed, 30 insertions, 6 deletions
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 7adf1a1d..9a2f3b56 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -101,6 +101,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -131,6 +132,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -158,6 +160,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -186,6 +189,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -214,6 +218,7 @@ impl Server {
revision: ident.rev_id.map(|v| v),
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -243,6 +248,7 @@ impl Server {
revision: ident.rev_id.map(|v| v),
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -269,6 +275,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -303,6 +310,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -338,6 +346,7 @@ impl Server {
revision: ident.rev_id,
redirect: ident.redirect_id.map(|u| u.to_string()),
editgroup_id: None,
+ extra: rev.extra_json,
};
Ok(Some(entity))
}
@@ -485,6 +494,7 @@ impl Api for Server {
revision: Some(edit.rev_id.unwrap()),
ident: Some(edit.ident_id.to_string()),
edit_id: Some(edit.id),
+ extra: edit.extra_json.clone(),
};
Box::new(futures::done(Ok(ContainerPostResponse::CreatedEntity(
entity_edit,
@@ -525,6 +535,7 @@ impl Api for Server {
revision: Some(edit.rev_id.unwrap()),
ident: Some(edit.ident_id.to_string()),
edit_id: Some(edit.id),
+ extra: edit.extra_json.clone(),
};
Box::new(futures::done(Ok(CreatorPostResponse::CreatedEntity(
entity_edit,
@@ -567,6 +578,7 @@ impl Api for Server {
revision: Some(edit.rev_id.unwrap()),
ident: Some(edit.ident_id.to_string()),
edit_id: Some(edit.id),
+ extra: edit.extra_json.clone(),
};
Box::new(futures::done(Ok(FilePostResponse::CreatedEntity(
entity_edit,
@@ -607,6 +619,7 @@ impl Api for Server {
revision: Some(edit.rev_id.unwrap()),
ident: Some(edit.ident_id.to_string()),
edit_id: Some(edit.id),
+ extra: edit.extra_json.clone(),
};
Box::new(futures::done(Ok(WorkPostResponse::CreatedEntity(
entity_edit,
@@ -660,6 +673,7 @@ impl Api for Server {
revision: Some(edit.rev_id.unwrap()),
ident: Some(edit.ident_id.to_string()),
edit_id: Some(edit.id),
+ extra: edit.extra_json.clone(),
};
Box::new(futures::done(Ok(ReleasePostResponse::CreatedEntity(
entity_edit,
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index d871d55d..732ceeeb 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -40,7 +40,7 @@ macro_rules! entity_structs {
pub rev_id: Option<i64>,
pub redirect_id: Option<Uuid>,
pub editgroup_id: i64,
- //pub extra_json: Option<serde_json::Value>,
+ pub extra_json: Option<serde_json::Value>,
}
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
@@ -72,7 +72,7 @@ macro_rules! entity_structs {
#[table_name = "container_rev"]
pub struct ContainerRevRow {
pub id: i64,
- //pub extra_json: Option<serde_json::Value>,
+ pub extra_json: Option<serde_json::Value>,
pub name: String,
pub publisher: Option<String>,
pub issn: Option<String>,
@@ -89,7 +89,7 @@ entity_structs!(
#[table_name = "creator_rev"]
pub struct CreatorRevRow {
pub id: i64,
- //extra_json: Option<String>,
+ pub extra_json: Option<serde_json::Value>,
pub name: String,
pub orcid: Option<String>,
}
@@ -105,7 +105,7 @@ entity_structs!(
#[table_name = "file_rev"]
pub struct FileRevRow {
pub id: i64,
- //extra_json: Option<String>,
+ pub extra_json: Option<serde_json::Value>,
pub size: Option<i64>,
pub sha1: Option<String>,
pub url: Option<String>,
@@ -117,7 +117,7 @@ entity_structs!("file_edit", FileEditRow, "file_ident", FileIdentRow);
#[table_name = "release_rev"]
pub struct ReleaseRevRow {
pub id: i64,
- //extra_json: Option<Json>,
+ pub extra_json: Option<serde_json::Value>,
pub work_ident_id: Uuid,
pub container_ident_id: Option<Uuid>,
pub title: String,
@@ -140,7 +140,7 @@ entity_structs!(
#[table_name = "work_rev"]
pub struct WorkRevRow {
pub id: i64,
- //extra_json: Option<Json>,
+ pub extra_json: Option<serde_json::Value>,
pub work_type: Option<String>,
pub primary_release_id: Option<Uuid>,
}
diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs
index 6856b19c..5ce407b6 100644
--- a/rust/src/database_schema.rs
+++ b/rust/src/database_schema.rs
@@ -9,6 +9,7 @@ table! {
table! {
container_edit (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
ident_id -> Uuid,
rev_id -> Nullable<Int8>,
redirect_id -> Nullable<Uuid>,
@@ -28,6 +29,7 @@ table! {
table! {
container_rev (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
name -> Text,
publisher -> Nullable<Text>,
issn -> Nullable<Text>,
@@ -37,6 +39,7 @@ table! {
table! {
creator_edit (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
ident_id -> Uuid,
rev_id -> Nullable<Int8>,
redirect_id -> Nullable<Uuid>,
@@ -56,6 +59,7 @@ table! {
table! {
creator_rev (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
name -> Text,
orcid -> Nullable<Text>,
}
@@ -82,6 +86,7 @@ table! {
table! {
file_edit (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
ident_id -> Uuid,
rev_id -> Nullable<Int8>,
redirect_id -> Nullable<Uuid>,
@@ -108,6 +113,7 @@ table! {
table! {
file_rev (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
size -> Nullable<Int8>,
sha1 -> Nullable<Text>,
url -> Nullable<Text>,
@@ -127,6 +133,7 @@ table! {
table! {
release_edit (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
ident_id -> Uuid,
rev_id -> Nullable<Int8>,
redirect_id -> Nullable<Uuid>,
@@ -156,6 +163,7 @@ table! {
table! {
release_rev (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
work_ident_id -> Uuid,
container_ident_id -> Nullable<Uuid>,
title -> Text,
@@ -171,6 +179,7 @@ table! {
table! {
work_edit (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
ident_id -> Uuid,
rev_id -> Nullable<Int8>,
redirect_id -> Nullable<Uuid>,
@@ -190,6 +199,7 @@ table! {
table! {
work_rev (id) {
id -> Int8,
+ extra_json -> Nullable<Json>,
work_type -> Nullable<Text>,
primary_release_id -> Nullable<Uuid>,
}