Skip to content

Commit

Permalink
Merge branch 'release/v0.12.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Sep 6, 2024
2 parents 66e2d59 + b746617 commit b2c51c8
Show file tree
Hide file tree
Showing 71 changed files with 3,402 additions and 620 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[0.12.9]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.9) - 2024-09-06
### Added
- [595](https://github.com/thoth-pub/thoth/issues/595), [626](https://github.com/thoth-pub/thoth/pull/626) - Remove infrequently used and unused work statuses (unspecified, no longer our product, out of stock indefinitely, out of print, inactive, unknown, remaindered, recalled). Require a publication date for active, withdrawn, and superseded works in Thoth. Add a new `Superseded` work status to replace Out of Print for older editions of Works. Require a withdrawn date for Superseded works.
- [582](https://github.com/thoth-pub/thoth/issues/582) - Add Crossmark metadata in Crossref DOI deposit when a Crossmark policy is present in the publisher record. Add Crossmark update new\_edition metadata when a book is replaced by a new edition, and withdrawal metadata when a book is withdrawn from sale.
- [574](https://github.com/thoth-pub/thoth/issues/574), [626](https://github.com/thoth-pub/thoth/pull/626) - Add descriptions to all remaining items in schema

### Fixed
- [548](https://github.com/thoth-pub/thoth/issues/548) - Prevent users from deleting contributors/institutions which are linked to works by other publishers

### Changed
- [623](https://github.com/thoth-pub/thoth/pull/623) - Convert connection pool errors (`r2d2::Error`) to `ThothError`
- [625](https://github.com/thoth-pub/thoth/pull/625) - Use relationcode 13 for physical ISBNs in ONIX 2.1 EBSCOHost output

## [[0.12.8]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.8) - 2024-09-03
### Fixed
- [622](https://github.com/thoth-pub/thoth/pull/622) - Fix bug where list of contributors in New/Edit Contribution form was truncated
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth"
version = "0.12.8"
version = "0.12.9"
authors = ["Javier Arias <javi@openbookpublishers.com>", "Ross Higman <ross@openbookpublishers.com>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -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.8", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "=0.12.8", path = "thoth-api-server" }
thoth-app-server = { version = "=0.12.8", path = "thoth-app-server" }
thoth-errors = { version = "=0.12.8", path = "thoth-errors" }
thoth-export-server = { version = "=0.12.8", path = "thoth-export-server" }
thoth-api = { version = "=0.12.9", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "=0.12.9", path = "thoth-api-server" }
thoth-app-server = { version = "=0.12.9", path = "thoth-app-server" }
thoth-errors = { version = "=0.12.9", path = "thoth-errors" }
thoth-export-server = { version = "=0.12.9", path = "thoth-export-server" }
clap = { version = "4.5.16", features = ["cargo", "env"] }
dialoguer = { version = "0.11.0", features = ["password"] }
dotenv = "0.15.0"
Expand Down
6 changes: 3 additions & 3 deletions thoth-api-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth-api-server"
version = "0.12.8"
version = "0.12.9"
authors = ["Javier Arias <javi@openbookpublishers.com>", "Ross Higman <ross@openbookpublishers.com>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -9,8 +9,8 @@ repository = "https://github.com/thoth-pub/thoth"
readme = "README.md"

[dependencies]
thoth-api = { version = "=0.12.8", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "=0.12.8", path = "../thoth-errors" }
thoth-api = { version = "=0.12.9", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "=0.12.9", path = "../thoth-errors" }
actix-web = "4.9"
actix-cors = "0.7.0"
actix-identity = "0.7.1"
Expand Down
4 changes: 2 additions & 2 deletions thoth-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth-api"
version = "0.12.8"
version = "0.12.9"
authors = ["Javier Arias <javi@openbookpublishers.com>", "Ross Higman <ross@openbookpublishers.com>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -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.8", path = "../thoth-errors" }
thoth-errors = { version = "=0.12.9", path = "../thoth-errors" }
actix-web = { version = "4.8", optional = true }
argon2rs = "0.2.5"
isbn2 = "0.4.0"
Expand Down
51 changes: 51 additions & 0 deletions thoth-api/migrations/v0.12.9/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ALTER TYPE work_status RENAME VALUE 'withdrawn' TO 'withdrawn-from-sale';

ALTER TABLE work
-- Drop constraints originally from v0.12.3,
-- otherwise it won't be able to cast to text
DROP CONSTRAINT IF EXISTS work_inactive_no_withdrawn_date_check,
DROP CONSTRAINT IF EXISTS work_active_withdrawn_date_check,
-- Drop new constraint from v.0.12.9
DROP CONSTRAINT IF EXISTS work_active_publication_date_check;

ALTER TABLE work ALTER COLUMN work_status TYPE text;

-- !!! if this down migration is run, 'out-of-print' should
-- be treated as a placeholder work_status.
-- Works will need to be manually reassigned correct work_status:
-- out-of-print, out-of-stock-indefinitely, or inactive
-- This needs to be run because superseded is a new work_status
-- that is removed in this down migration.
UPDATE work
SET work_status = 'out-of-print'
WHERE work_status = 'superseded';

DROP TYPE work_status;

CREATE TYPE work_status AS ENUM (
'unspecified',
'cancelled',
'forthcoming',
'postponed-indefinitely',
'active',
'no-longer-our-product',
'out-of-stock-indefinitely',
'out-of-print',
'inactive',
'unknown',
'remaindered',
'withdrawn-from-sale',
'recalled'
);

ALTER TABLE work ALTER COLUMN work_status TYPE work_status USING work_status::work_status;

-- add constraints back to work table
ALTER TABLE work
ADD CONSTRAINT work_active_withdrawn_date_check CHECK
((work_status = 'withdrawn-from-sale' OR work_status = 'out-of-print')
OR (work_status NOT IN ('withdrawn-from-sale', 'out-of-print') AND withdrawn_date IS NULL)),

ADD CONSTRAINT work_inactive_no_withdrawn_date_check CHECK
(((work_status = 'withdrawn-from-sale' OR work_status = 'out-of-print') AND withdrawn_date IS NOT NULL)
OR (work_status NOT IN ('withdrawn-from-sale', 'out-of-print')));
104 changes: 104 additions & 0 deletions thoth-api/migrations/v0.12.9/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
ALTER TYPE work_status RENAME VALUE 'withdrawn-from-sale' TO 'withdrawn';

-- Assign 1900-01-01 as placeholder publication_date for
-- Active, withdrawn from sale, out of print, out of stock indefinitely works with no publication date
-- Required for work_active_publication_date_check constraint below
-- Affected works in production db with this status, 29-05-2024: 59 works (incl. chapters)
-- Before running migration, make a list of affected works
-- After running migration, publishers should be notified to add correct publication_date
-- !!! This is irreversible
UPDATE work
SET
publication_date = '1900-01-01'
WHERE
work_status IN
('active', 'withdrawn', 'out-of-print', 'out-of-stock-indefinitely', 'inactive')
AND publication_date IS NULL;

-- Drop constraints, otherwise it won't be able to cast to text
ALTER TABLE work
DROP CONSTRAINT IF EXISTS work_active_withdrawn_date_check,
DROP CONSTRAINT IF EXISTS work_inactive_no_withdrawn_date_check;

ALTER TABLE work ALTER COLUMN work_status TYPE text;

-- delete unused work_status enum
DROP TYPE work_status;

-- Assign out of print/inactive/out of stock indefinitely works work_status 'superseded'
-- current counts in production db as of 29-05-2024:
-- 145 works (incl. chapters)
-- Before running migration, make a list of affected works
-- After running migration, publishers should be notified to add correct work_status
-- and remove withdrawn_date as necessary. Many OBP "out of print" works are actually first editions
-- for which superseded is the correct new work_status.
-- !!! This is irreversible
UPDATE work
SET
work_status = 'superseded',
-- assign a withdrawn_date, which is required for superseded works
withdrawn_date = CASE
WHEN withdrawn_date IS NOT NULL THEN withdrawn_date
-- + INTERVAL '1 day' is necessary because at least one work has publication_date on
-- the same day as updated_at, but updated_at has a timestamp, so it's
-- greater than. Which then throws an error with the
-- work_withdrawn_date_after_publication_date_check constraint.
WHEN withdrawn_date IS NULL AND publication_date + INTERVAL '1 day' < updated_at THEN updated_at
ELSE CURRENT_DATE
END
WHERE
work_status = 'out-of-print'
OR work_status = 'out-of-stock-indefinitely'
OR work_status = 'inactive';

-- Assign unspecified/unkown works work_status 'forthcoming'
-- current counts in production db as of 29-05-2024:
-- unspecified, 0 works
-- unknown, 0 works
-- !!! This is irreversible
UPDATE work
SET work_status = 'forthcoming'
WHERE work_status = 'unspecified' OR work_status = 'unknown';

-- Assign no longer our product/remaindered/recalled works work_status 'withdrawn-from-sale'
-- current counts in production db as of 29-05-2024:
-- no-longer-our-product, 0 works
-- remaindered, 0 works
-- recalled, 0 works
-- !!! This is irreversible
UPDATE work
SET
work_status = 'withdrawn',
withdrawn_date = COALESCE(withdrawn_date, updated_at)
WHERE
work_status = 'no-longer-our-product'
OR work_status = 'remaindered'
OR work_status = 'recalled';

-- create new work_status enum, adds superseded
CREATE TYPE work_status AS ENUM (
'cancelled',
'forthcoming',
'postponed-indefinitely',
'active',
'withdrawn',
'superseded'
);
ALTER TABLE work ALTER COLUMN work_status TYPE work_status USING work_status::work_status;

-- add new constraints (with same names as in v0.12.3) to work table
ALTER TABLE work
-- withdrawn and superseded works must have withdrawn_date
-- note that this constraint has the same name as migration from v.0.12.3,
-- but changes previous constraint by adding superseded alongside withdrawn
ADD CONSTRAINT work_inactive_no_withdrawn_date_check CHECK
(((work_status = 'withdrawn' OR work_status = 'superseded') AND withdrawn_date IS NOT NULL)
OR (work_status NOT IN ('withdrawn', 'superseded'))),
-- all other work statuses must not have withdrawn_date; see above, adds superseded
ADD CONSTRAINT work_active_withdrawn_date_check CHECK
((work_status = 'withdrawn' OR work_status = 'superseded')
OR (work_status NOT IN ('withdrawn', 'superseded') AND withdrawn_date IS NULL)),
-- active, withdrawn-from-sale, and superseded works must have publication_date
ADD CONSTRAINT work_active_publication_date_check CHECK
((work_status IN ('active', 'withdrawn', 'superseded') AND publication_date IS NOT NULL)
OR (work_status NOT IN ('active', 'withdrawn', 'superseded')));
Loading

0 comments on commit b2c51c8

Please sign in to comment.