From 68cbd39c9d8b274bb88e211cce0785e6f54953f5 Mon Sep 17 00:00:00 2001 From: Claire Lovisa Date: Mon, 14 Jul 2025 16:23:22 +0200 Subject: [PATCH 1/2] Add migration to fix dev addresses --- CHANGELOG.md | 2 +- ...nked-to-both-site-and-contact-point.sparql | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql diff --git a/CHANGELOG.md b/CHANGELOG.md index 7208f72..7a5ec9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +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] ### Deploy notes ``` drc pull scope-of-operation; drc up -d scope-of-operation @@ -32,7 +33,6 @@ drc restart migrations; drc logs -ft --tail=200 migrations - Add URI to resource's organization responses - Fix query for organizations report [OP-3636] - Bump report-generation-service to most recent version -- Write migration to harmonize date formats of change events [OP-3559] ### Deploy notes ``` drc pull deltanotifier; drc up -d deltanotifier diff --git a/config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql b/config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql new file mode 100644 index 0000000..24d41a3 --- /dev/null +++ b/config/dev-migrations/20250708142100-fix-same-address-linked-to-both-site-and-contact-point.sparql @@ -0,0 +1,31 @@ +DELETE { + GRAPH ?h { + ?site ?oldAddressUri . + } +} INSERT { + GRAPH ?g { + ?newAddressUri a ; + ?newAddressUuid ; + ?p ?o . + } + + GRAPH ?h { + ?site ?newAddressUri . + } +} WHERE { + GRAPH ?g { + ?oldAddressUri a ; + ?p ?o . + + FILTER (?p NOT IN ()) + } + + ?mandatarisContact ?oldAddressUri . + + GRAPH ?h { + ?site ?oldAddressUri . + } + + BIND(MD5(CONCAT(?oldAddressUri,"OLD_ADDRESS")) AS ?newAddressUuid) . + BIND(IRI(CONCAT("http://data.lblod.info/id/adressen/", STR(?newAddressUuid))) AS ?newAddressUri) . +} From e1eca4b18528e780a43fb25a4521b7f5cbccad40 Mon Sep 17 00:00:00 2001 From: Claire Lovisa Date: Tue, 22 Jul 2025 12:01:01 +0200 Subject: [PATCH 2/2] 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 . + } +}