From e1eca4b18528e780a43fb25a4521b7f5cbccad40 Mon Sep 17 00:00:00 2001 From: Claire Lovisa Date: Tue, 22 Jul 2025 12:01:01 +0200 Subject: [PATCH] Add cleanup of addresses graph and move to regular migrations --- CHANGELOG.md | 2 +- ...inked-to-both-site-and-contact-point.sparql | 7 +++---- ...ntact-addresses-being-in-wrong-graph.sparql | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) rename config/{dev-migrations => migrations/2025}/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql (79%) create mode 100644 config/migrations/2025/20250722114200-fix-contact-addresses-being-in-wrong-graph.sparql diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5ec9f..77591e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Add a service to manage organisation's their scope of operation [OP-3205] - datamodel: Allow a location to be within multiple other locations [OP-3205] - datafix: set scope of operation for worship administrative units [OP-3626] -- Clean dev addresses linked to both sites and contact points of mandatarissen [DL-6701] +- Clean addresses linked to both sites and contact points of mandatarissen and addresses that are in the wrong graph (admin unit graph but linked to a contact point in the worship graph) [DL-6701] ### Deploy notes ``` drc pull scope-of-operation; drc up -d scope-of-operation diff --git a/config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql b/config/migrations/2025/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql similarity index 79% rename from config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql rename to config/migrations/2025/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql index 24d41a3..bbd4003 100644 --- a/config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql +++ b/config/migrations/2025/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql @@ -7,9 +7,7 @@ DELETE { ?newAddressUri a ; ?newAddressUuid ; ?p ?o . - } - GRAPH ?h { ?site ?newAddressUri . } } WHERE { @@ -23,9 +21,10 @@ DELETE { ?mandatarisContact ?oldAddressUri . GRAPH ?h { - ?site ?oldAddressUri . + ?site a ; + ?oldAddressUri . } - BIND(MD5(CONCAT(?oldAddressUri,"OLD_ADDRESS")) AS ?newAddressUuid) . + BIND(MD5(CONCAT(?oldAddressUri,"NEW_ADDRESS")) AS ?newAddressUuid) . BIND(IRI(CONCAT("http://data.lblod.info/id/adressen/", STR(?newAddressUuid))) AS ?newAddressUri) . } diff --git a/config/migrations/2025/20250722114200-fix-contact-addresses-being-in-wrong-graph.sparql b/config/migrations/2025/20250722114200-fix-contact-addresses-being-in-wrong-graph.sparql new file mode 100644 index 0000000..d91d279 --- /dev/null +++ b/config/migrations/2025/20250722114200-fix-contact-addresses-being-in-wrong-graph.sparql @@ -0,0 +1,18 @@ +DELETE { + GRAPH { + ?address ?p ?o . + } +} INSERT { + GRAPH { + ?address ?p ?o . + } +} WHERE { + GRAPH { + ?contactPoint a ; + ?address . + } + + GRAPH { + ?address ?p ?o . + } +}