From cf858c018fd60c220d5c8a617809f64d8612971b Mon Sep 17 00:00:00 2001 From: rhigman <73792779+rhigman@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:37:51 +0100 Subject: [PATCH 1/3] Add location migrations and update enum to include Zenodo --- CHANGELOG.md | 2 ++ thoth-api/migrations/v0.12.4/down.sql | 33 +++++++++++++++++++++++++++ thoth-api/migrations/v0.12.4/up.sql | 1 + thoth-api/src/model/location/mod.rs | 8 +++++++ 4 files changed, 44 insertions(+) create mode 100644 thoth-api/migrations/v0.12.4/down.sql create mode 100644 thoth-api/migrations/v0.12.4/up.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bcc4e3d..dadd6ef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed + - [545](https://github.com/thoth-pub/thoth/issues/545) - Add Zenodo as a location platform ## [[0.12.3]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.3) - 2024-04-26 ### Added diff --git a/thoth-api/migrations/v0.12.4/down.sql b/thoth-api/migrations/v0.12.4/down.sql new file mode 100644 index 00000000..96df703e --- /dev/null +++ b/thoth-api/migrations/v0.12.4/down.sql @@ -0,0 +1,33 @@ +UPDATE location SET location_platform = 'Other' WHERE location_platform = 'Zenodo'; + +-- Drop the default and unique constraint, otherwise it won't be able to cast to text +ALTER TABLE location ALTER COLUMN location_platform DROP DEFAULT; +DROP INDEX location_uniq_platform_idx; + +ALTER TABLE location ALTER COLUMN location_platform TYPE text; +DROP TYPE location_platform; +CREATE TYPE location_platform AS ENUM ( + 'Project MUSE', + 'OAPEN', + 'DOAB', + 'JSTOR', + 'EBSCO Host', + 'OCLC KB', + 'ProQuest KB', + 'ProQuest ExLibris', + 'EBSCO KB', + 'JISC KB', + 'Google Books', + 'Internet Archive', + 'ScienceOpen', + 'SciELO Books', + 'Publisher Website', + 'Other' + ); +ALTER TABLE location ALTER location_platform TYPE location_platform USING location_platform::location_platform; +ALTER TABLE location + ALTER COLUMN location_platform SET DEFAULT 'Other'::location_platform; + +CREATE UNIQUE INDEX location_uniq_platform_idx + ON location (publication_id, location_platform) + WHERE NOT location_platform = 'Other'::location_platform; diff --git a/thoth-api/migrations/v0.12.4/up.sql b/thoth-api/migrations/v0.12.4/up.sql new file mode 100644 index 00000000..6aadfa98 --- /dev/null +++ b/thoth-api/migrations/v0.12.4/up.sql @@ -0,0 +1 @@ +ALTER TYPE location_platform ADD VALUE IF NOT EXISTS 'Zenodo'; diff --git a/thoth-api/src/model/location/mod.rs b/thoth-api/src/model/location/mod.rs index faf28c29..2ed0c375 100644 --- a/thoth-api/src/model/location/mod.rs +++ b/thoth-api/src/model/location/mod.rs @@ -60,6 +60,9 @@ pub enum LocationPlatform { #[cfg_attr(feature = "backend", db_rename = "SciELO Books")] #[strum(serialize = "SciELO Books")] ScieloBooks, + #[cfg_attr(feature = "backend", db_rename = "Zenodo")] + #[strum(serialize = "Zenodo")] + Zenodo, #[cfg_attr(feature = "backend", db_rename = "Publisher Website")] #[strum(serialize = "Publisher Website")] PublisherWebsite, @@ -183,6 +186,7 @@ fn test_locationplatform_display() { ); assert_eq!(format!("{}", LocationPlatform::ScienceOpen), "ScienceOpen"); assert_eq!(format!("{}", LocationPlatform::ScieloBooks), "SciELO Books"); + assert_eq!(format!("{}", LocationPlatform::Zenodo), "Zenodo"); assert_eq!( format!("{}", LocationPlatform::PublisherWebsite), "Publisher Website" @@ -249,6 +253,10 @@ fn test_locationplatform_fromstr() { LocationPlatform::from_str("SciELO Books").unwrap(), LocationPlatform::ScieloBooks ); + assert_eq!( + LocationPlatform::from_str("Zenodo").unwrap(), + LocationPlatform::Zenodo + ); assert_eq!( LocationPlatform::from_str("Publisher Website").unwrap(), LocationPlatform::PublisherWebsite From 567dac444d56364d9836c99af1b4f7e3d196953a Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Tue, 30 Apr 2024 08:42:57 +0100 Subject: [PATCH 2/3] Bump v0.12.4 --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 12 ++++++------ thoth-api-server/Cargo.toml | 6 +++--- thoth-api/Cargo.toml | 4 ++-- thoth-app-server/Cargo.toml | 2 +- thoth-app/Cargo.toml | 6 +++--- thoth-client/Cargo.toml | 8 ++++---- thoth-errors/Cargo.toml | 2 +- thoth-export-server/Cargo.toml | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1cd6f6d..c5799687 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3087,7 +3087,7 @@ dependencies = [ [[package]] name = "thoth" -version = "0.12.3" +version = "0.12.4" dependencies = [ "cargo-husky", "clap", @@ -3102,7 +3102,7 @@ dependencies = [ [[package]] name = "thoth-api" -version = "0.12.3" +version = "0.12.4" dependencies = [ "actix-web", "argon2rs", @@ -3131,7 +3131,7 @@ dependencies = [ [[package]] name = "thoth-api-server" -version = "0.12.3" +version = "0.12.4" dependencies = [ "actix-cors", "actix-identity", @@ -3147,7 +3147,7 @@ dependencies = [ [[package]] name = "thoth-app" -version = "0.12.3" +version = "0.12.4" dependencies = [ "anyhow", "chrono", @@ -3176,7 +3176,7 @@ dependencies = [ [[package]] name = "thoth-app-server" -version = "0.12.3" +version = "0.12.4" dependencies = [ "actix-cors", "actix-web", @@ -3186,7 +3186,7 @@ dependencies = [ [[package]] name = "thoth-client" -version = "0.12.3" +version = "0.12.4" dependencies = [ "chrono", "graphql_client", @@ -3202,7 +3202,7 @@ dependencies = [ [[package]] name = "thoth-errors" -version = "0.12.3" +version = "0.12.4" dependencies = [ "actix-web", "csv", @@ -3223,7 +3223,7 @@ dependencies = [ [[package]] name = "thoth-export-server" -version = "0.12.3" +version = "0.12.4" dependencies = [ "actix-cors", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 9b3ef07f..300c1c06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -16,11 +16,11 @@ maintenance = { status = "actively-developed" } members = ["thoth-api", "thoth-api-server", "thoth-app", "thoth-app-server", "thoth-client", "thoth-errors", "thoth-export-server"] [dependencies] -thoth-api = { version = "0.12.3", path = "thoth-api", features = ["backend"] } -thoth-api-server = { version = "0.12.3", path = "thoth-api-server" } -thoth-app-server = { version = "0.12.3", path = "thoth-app-server" } -thoth-errors = { version = "0.12.3", path = "thoth-errors" } -thoth-export-server = { version = "0.12.3", path = "thoth-export-server" } +thoth-api = { version = "=0.12.4", path = "thoth-api", features = ["backend"] } +thoth-api-server = { version = "=0.12.4", path = "thoth-api-server" } +thoth-app-server = { version = "=0.12.4", path = "thoth-app-server" } +thoth-errors = { version = "=0.12.4", path = "thoth-errors" } +thoth-export-server = { version = "=0.12.4", path = "thoth-export-server" } clap = { version = "4.4.7", features = ["cargo", "env"] } dialoguer = { version = "0.11.0", features = ["password"] } dotenv = "0.15.0" diff --git a/thoth-api-server/Cargo.toml b/thoth-api-server/Cargo.toml index 36526b03..e70f8326 100644 --- a/thoth-api-server/Cargo.toml +++ b/thoth-api-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-api-server" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -9,8 +9,8 @@ repository = "https://github.com/thoth-pub/thoth" readme = "README.md" [dependencies] -thoth-api = { version = "0.12.3", path = "../thoth-api", features = ["backend"] } -thoth-errors = { version = "0.12.3", path = "../thoth-errors" } +thoth-api = { version = "=0.12.4", path = "../thoth-api", features = ["backend"] } +thoth-errors = { version = "=0.12.4", path = "../thoth-errors" } actix-web = "4.5.1" actix-cors = "0.7.0" actix-identity = "0.7.1" diff --git a/thoth-api/Cargo.toml b/thoth-api/Cargo.toml index 55d44a2f..6724e10f 100644 --- a/thoth-api/Cargo.toml +++ b/thoth-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-api" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -16,7 +16,7 @@ maintenance = { status = "actively-developed" } backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web", "jsonwebtoken"] [dependencies] -thoth-errors = { version = "0.12.3", path = "../thoth-errors" } +thoth-errors = { version = "=0.12.4", path = "../thoth-errors" } actix-web = { version = "4.5.1", optional = true } argon2rs = "0.2.5" isbn2 = "0.4.0" diff --git a/thoth-app-server/Cargo.toml b/thoth-app-server/Cargo.toml index 1130d2c2..802b5738 100644 --- a/thoth-app-server/Cargo.toml +++ b/thoth-app-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-app-server" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" diff --git a/thoth-app/Cargo.toml b/thoth-app/Cargo.toml index 17d5454e..07d0198b 100644 --- a/thoth-app/Cargo.toml +++ b/thoth-app/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-app" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -36,8 +36,8 @@ uuid = { version = "0.8.2", features = ["serde", "v4"] } # `getrandom` is a dependency of `uuid`, we need to explicitly import and include the `js` feature to enable wasm # https://docs.rs/getrandom/latest/getrandom/#webassembly-support getrandom = { version = "0.2", features = ["js"] } -thoth-api = { version = "0.12.3", path = "../thoth-api" } -thoth-errors = { version = "0.12.3", path = "../thoth-errors" } +thoth-api = { version = "=0.12.4", path = "../thoth-api" } +thoth-errors = { version = "=0.12.4", path = "../thoth-errors" } [build-dependencies] dotenv = "0.15.0" diff --git a/thoth-client/Cargo.toml b/thoth-client/Cargo.toml index aa758b38..f0fc25a3 100644 --- a/thoth-client/Cargo.toml +++ b/thoth-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-client" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -10,8 +10,8 @@ readme = "README.md" build = "build.rs" [dependencies] -thoth-api = {version = "0.12.3", path = "../thoth-api" } -thoth-errors = {version = "0.12.3", path = "../thoth-errors" } +thoth-api = {version = "=0.12.4", path = "../thoth-api" } +thoth-errors = {version = "=0.12.4", path = "../thoth-errors" } graphql_client = "0.13.0" chrono = { version = "0.4.31", features = ["serde"] } reqwest = { version = "0.11", features = ["json"] } @@ -22,4 +22,4 @@ serde_json = "1.0" uuid = { version = "0.8.2", features = ["serde"] } [build-dependencies] -thoth-api = { version = "0.12.3", path = "../thoth-api", features = ["backend"] } +thoth-api = { version = "=0.12.4", path = "../thoth-api", features = ["backend"] } diff --git a/thoth-errors/Cargo.toml b/thoth-errors/Cargo.toml index 1438788d..c8eb0669 100644 --- a/thoth-errors/Cargo.toml +++ b/thoth-errors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-errors" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" diff --git a/thoth-export-server/Cargo.toml b/thoth-export-server/Cargo.toml index e73f3257..55ab9657 100644 --- a/thoth-export-server/Cargo.toml +++ b/thoth-export-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-export-server" -version = "0.12.3" +version = "0.12.4" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -10,9 +10,9 @@ readme = "README.md" build = "build.rs" [dependencies] -thoth-api = { version = "0.12.3", path = "../thoth-api" } -thoth-errors = { version = "0.12.3", path = "../thoth-errors" } -thoth-client = { version = "0.12.3", path = "../thoth-client" } +thoth-api = { version = "=0.12.4", path = "../thoth-api" } +thoth-errors = { version = "=0.12.4", path = "../thoth-errors" } +thoth-client = { version = "=0.12.4", path = "../thoth-client" } actix-web = "4.5.1" actix-cors = "0.7.0" cc_license = "0.1.0" From 01616726fff49d7ea1380dd62c3d35e1a5f6fff4 Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Tue, 30 Apr 2024 08:43:39 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dadd6ef1..3a875d6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [[0.12.4]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.4) - 2024-04-30 ### Changed - [545](https://github.com/thoth-pub/thoth/issues/545) - Add Zenodo as a location platform