diff --git a/config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql b/config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql new file mode 100644 index 0000000..620e86a --- /dev/null +++ b/config/migrations/2022/20220905103740-delete-primary-when-secondary.sparql @@ -0,0 +1,24 @@ +PREFIX locn: +PREFIX schema: +PREFIX rdf: +PREFIX rdfs: +DELETE { + GRAPH { + ?secondary + schema:contactType "Primary" + } +} +WHERE { + GRAPH { + ?primary + a schema:ContactPoint; + locn:address ?a1; + schema:telephone ?t1. + ?mandataris schema:contactPoint ?primary, ?secondary. + ?secondary + schema:telephone ?t2. + FILTER NOT EXISTS { + ?secondary locn:address ?a2. + } + } +} \ No newline at end of file