Add migration to fix MDV place

This commit is contained in:
Yura Bondarenko
2021-11-04 12:29:01 +01:00
parent 7fda074543
commit 9df531299b

View File

@@ -0,0 +1,21 @@
--
-- 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/
--
----------------------------------------------------
-- Make sure the metadatavalue.place column starts at 0 instead of 1
----------------------------------------------------
UPDATE metadatavalue AS mdv
SET place = mdv.place - minplace
FROM (
SELECT dspace_object_id, metadata_field_id, MIN(place) AS minplace
FROM metadatavalue
GROUP BY dspace_object_id, metadata_field_id
) AS mp
WHERE mdv.dspace_object_id = mp.dspace_object_id
AND mdv.metadata_field_id = mp.metadata_field_id
AND minplace > 0;