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