diff --git a/config/migrations/2025/20250725120411-fix-reversed-memberships-ocmw-municipality.sparql b/config/migrations/2025/20250725120411-fix-reversed-memberships-ocmw-municipality.sparql new file mode 100644 index 0000000..a170150 --- /dev/null +++ b/config/migrations/2025/20250725120411-fix-reversed-memberships-ocmw-municipality.sparql @@ -0,0 +1,40 @@ +PREFIX org: +PREFIX mu: + +DELETE { + GRAPH { + ?membership org:organization ?ocmw ; + org:member ?municipality . + } +} +INSERT { + GRAPH { + ?membership org:organization ?municipality ; + org:member ?ocmw . + } +} +WHERE { + GRAPH { + ?membership a org:Membership ; + org:organization ?ocmw ; + org:member ?municipality ; + org:role . + } + + GRAPH ?graphMunicipality { + ?municipality org:classification . + } + + GRAPH ?graphOCMW { + ?ocmw org:classification . + } + + FILTER NOT EXISTS { + GRAPH { + ?correctMembership a org:Membership ; + org:organization ?municipality ; + org:member ?ocmw ; + org:role . + } + } +}