diff --git a/CHANGELOG.md b/CHANGELOG.md index 19398b2..f398119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Deploy notes ``` drc restart migrations; drc logs -ft --tail=200 migrations +drc exec db-cleanup curl -X POST "http://localhost/cleanup" ``` ## v1.32.1 (2025-06-02) diff --git a/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.graph b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.graph new file mode 100644 index 0000000..d5c0765 --- /dev/null +++ b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.graph @@ -0,0 +1 @@ +http://mu.semte.ch/graphs/public \ No newline at end of file diff --git a/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.ttl b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.ttl new file mode 100644 index 0000000..87febc3 --- /dev/null +++ b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.ttl @@ -0,0 +1,36 @@ +@prefix cleanup: . +@prefix mu: . +@prefix dcterms: . + +# Insert triples of the form +# +# matching memberships for which no such triple exists. + +# Province: +# +# Municipality: + + a cleanup:Job ; + mu:uuid "0cc5e981-a61e-433e-b6f2-c59fd8599944" ; + dcterms:title "Insert missing `org:hasSubOrganization` triples relating provinces and municipalities." ; + cleanup:randomQuery """ + PREFIX org: + + INSERT { + GRAPH { + ?province org:hasSubOrganization ?municipality . + } + } WHERE { + GRAPH { + ?membership a org:Membership ; + org:organization ?province ; + org:member ?municipality ; + org:role . + + FILTER NOT EXISTS { ?province org:hasSubOrganization ?municipality . } + + ?municipality org:classification . + ?province org:classification . + } + } + """ . diff --git a/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603164149-feat--cleanup-job-delete-suborganization-province-municipality.graph b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603164149-feat--cleanup-job-delete-suborganization-province-municipality.graph new file mode 100644 index 0000000..092c3a9 --- /dev/null +++ b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603164149-feat--cleanup-job-delete-suborganization-province-municipality.graph @@ -0,0 +1 @@ +http://mu.semte.ch/graphs/public diff --git a/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603164149-feat--cleanup-job-delete-suborganization-province-municipality.ttl b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603164149-feat--cleanup-job-delete-suborganization-province-municipality.ttl new file mode 100644 index 0000000..0b2dee1 --- /dev/null +++ b/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603164149-feat--cleanup-job-delete-suborganization-province-municipality.ttl @@ -0,0 +1,37 @@ +@prefix cleanup: . +@prefix mu: . +@prefix dcterms: . + +# Delete triples of the form +# +# for which no matching membership exists. + +# Province: +# +# Municipality: + + a cleanup:Job ; + mu:uuid "7354dfd9-bdef-48d6-b81e-e814bd4f4e9c" ; + dcterms:title "Delete leftover `org:hasSubOrganization` triples between Provinces and municipalities." ; + cleanup:randomQuery """ + PREFIX org: + + DELETE { + GRAPH { + ?province org:hasSubOrganization ?municipality . + } + } WHERE { + GRAPH { + ?province org:hasSubOrganization ?municipality . + FILTER NOT EXISTS { + ?membership a org:Membership ; + org:organization ?province ; + org:member ?municipality ; + org:role . + } + + ?municipality org:classification . + ?province org:classification . + } + } + """ .