-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional changes needed for the optimized "embargo publication date…
…" aggregate. #9763
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/resources/db/migration/V6.0.0.1__9763-embargocitationdate.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- An aggregated timestamp which is the latest of the availability dates of any embargoed files in the first published version, if present | ||
ALTER TABLE dataset ADD COLUMN IF NOT EXISTS embargoCitationDate timestamp without time zone; | ||
-- ... and an update query that will populate this column for all the published datasets with embargoed files in the first released version: | ||
UPDATE dataset SET embargocitationdate=o.embargocitationdate | ||
FROM (SELECT d.id, MAX(e.dateavailable) AS embargocitationdate | ||
FROM embargo e, dataset d, datafile f, datasetversion v, filemetadata m | ||
WHERE v.dataset_id = d.id | ||
AND v.versionstate = 'RELEASED' | ||
AND v.versionnumber = 1 | ||
AND v.minorversionnumber = 0 | ||
AND f.embargo_id = e.id | ||
AND m.datasetversion_id = v.id | ||
AND m.datafile_id = f.id GROUP BY d.id) o WHERE o.id = dataset.id; | ||
-- (the query follows the logic that used to be in the method Dataset.getCitationDate() that calculated this adjusted date in real time). |