Skip to content

Commit

Permalink
106798: update migration for H2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout-atmire committed Dec 23, 2024
1 parent bd087ec commit a9f1776
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
--

-- In the workspaceitem table, if there are multiple rows referring to the same item ID, keep only the first of them.
WITH dedup AS (
SELECT item_id, MIN(workspace_item_id) AS workspace_item_id
DELETE FROM workspaceitem WHERE EXISTS (
SELECT item_id
FROM workspaceitem
GROUP BY item_id
HAVING COUNT(workspace_item_id) > 1
)
DELETE FROM workspaceitem
USING dedup
WHERE workspaceitem.item_id = dedup.item_id AND workspaceitem.workspace_item_id <> dedup.workspace_item_id;

) AND workspaceitem.workspace_item_id NOT IN (
SELECT MIN(workspace_item_id) AS workspace_item_id
FROM workspaceitem
GROUP BY item_id
);
-- Identify which rows have duplicates, and compute their replacements.
ALTER TABLE workspaceitem ADD CONSTRAINT unique_item_id UNIQUE(item_id);

0 comments on commit a9f1776

Please sign in to comment.