forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DSpace#9106 from paulo-graca/bugfix/issue-9099
Clear primary bistream when it's deleted- Fix issue DSpace#9099
- Loading branch information
Showing
5 changed files
with
120 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
...e/storage/rdbms/sqlmigration/postgres/V7.6_2023.10.12__Fix-deleted-primary-bitstreams.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,34 @@ | ||
-- | ||
-- The contents of this file are subject to the license and copyright | ||
-- detailed in the LICENSE and NOTICE files at the root of the source | ||
-- tree and available online at | ||
-- | ||
-- http://www.dspace.org/license/ | ||
-- | ||
|
||
BEGIN; | ||
|
||
-- Unset any primary bitstream that is marked as deleted | ||
UPDATE bundle | ||
SET primary_bitstream_id = NULL | ||
WHERE primary_bitstream_id IN | ||
( SELECT bs.uuid | ||
FROM bitstream AS bs | ||
INNER JOIN bundle as bl ON bs.uuid = bl.primary_bitstream_id | ||
WHERE bs.deleted IS TRUE ); | ||
|
||
-- Unset any primary bitstream that don't belong to bundle's bitstream list | ||
UPDATE bundle | ||
SET primary_bitstream_id = NULL | ||
WHERE primary_bitstream_id IN | ||
( SELECT bl.primary_bitstream_id | ||
FROM bundle as bl | ||
WHERE bl.primary_bitstream_id IS NOT NULL | ||
AND bl.primary_bitstream_id NOT IN | ||
( SELECT bitstream_id | ||
FROM bundle2bitstream AS b2b | ||
WHERE b2b.bundle_id = bl.uuid | ||
) | ||
); | ||
|
||
COMMIT; |
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