diff --git a/CHANGELOG.md b/CHANGELOG.md index 77591e4..cadb2f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - datamodel: Allow a location to be within multiple other locations [OP-3205] - datafix: set scope of operation for worship administrative units [OP-3626] - 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] +- datafix: cleanup of general memberships if specific ones exist [OP-3640] ### Deploy notes ``` drc pull scope-of-operation; drc up -d scope-of-operation diff --git a/config/migrations/2025/20250718132455-remove-general-memberships-if-specifics-exists.sparql b/config/migrations/2025/20250718132455-remove-general-memberships-if-specifics-exists.sparql new file mode 100644 index 0000000..ecf8e78 --- /dev/null +++ b/config/migrations/2025/20250718132455-remove-general-memberships-if-specifics-exists.sparql @@ -0,0 +1,33 @@ +PREFIX org: +PREFIX mu: +PREFIX skos: + +DELETE { + GRAPH ?g { + ?membership ?p ?o . + } +} +WHERE { + GRAPH ?g { + # Find memberships that use the general 'gerelateerd' role + ?membership a org:Membership ; + org:role ; + org:member ?orgMember ; + org:organization ?organization . + + # Only delete if there's a specific role for the inverse membership + FILTER EXISTS { + ?specific_membership a org:Membership ; + org:member ?organization ; + org:organization ?orgMember ; + org:role ?specificRole . + + VALUES ?specificRole { + # participant + # stichtend lid + } + } + + ?membership ?p ?o . + } +}