From 97361f7f48a26496fc4de09c8f39f4b564175cb7 Mon Sep 17 00:00:00 2001 From: Laurent Deketelaere Date: Wed, 5 Jun 2024 08:38:22 +0200 Subject: [PATCH] fix: Add migration to delete duplicate identifier --- ...4100500-delete-duplicate-identifier.sparql | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 config/migrations/2024/20240604100500-delete-duplicate-identifier.sparql diff --git a/config/migrations/2024/20240604100500-delete-duplicate-identifier.sparql b/config/migrations/2024/20240604100500-delete-duplicate-identifier.sparql new file mode 100644 index 0000000..92b0cfd --- /dev/null +++ b/config/migrations/2024/20240604100500-delete-duplicate-identifier.sparql @@ -0,0 +1,33 @@ +DELETE { + GRAPH ?g { + ?org ?identifier . + ?identifier ?pi ?oi . + ?structured ?ps ?os . + } +} +WHERE { + GRAPH ?g { + { + # Select one identifier by organization and local identifier + SELECT ?org ?li (MAX(?i) AS ?keepIdentifier) WHERE { + ?org ?i . + ?i / ?li . + } GROUP BY ?org ?li + } + + ?org ?identifier . + ?identifier ?structured . + ?structured ?li . + + FILTER(?identifier != ?keepIdentifier) + + # All properties of the duplicate identifier and structured identifier + ?identifier ?pi ?oi . + ?structured ?ps ?os . + } + + VALUES ?g { + + + } +} \ No newline at end of file