Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation resources were not renamed #222

Closed
EfraimFeinstein opened this issue Nov 3, 2021 · 2 comments
Closed

Annotation resources were not renamed #222

EfraimFeinstein opened this issue Nov 3, 2021 · 2 comments

Comments

@EfraimFeinstein
Copy link
Member

When resources were renamed, annotation resources (and the references to them) were not renamed. This means that there are now inconsistent names in the database.

@EfraimFeinstein
Copy link
Member Author

Run this script on the db:

xquery version "3.1";

import module namespace data="http://jewishliturgy.org/modules/data" at "xmldb:exist://db/apps/opensiddur-server/modules/data.xqm";
import module namespace didx="http://jewishliturgy.org/modules/docindex" at "xmldb:exist://db/apps/opensiddur-server/modules/docindex.xqm";
import module namespace ridx="http://jewishliturgy.org/modules/refindex" at "xmldb:exist://db/apps/opensiddur-server/modules/refindex.xqm";

(
for $doc in collection("/db/data/notes")
let $doc-uri := document-uri($doc)
let $collection := util:collection-name($doc)
let $old-name := replace(util:document-name($doc), ".xml", "")
let $new-name :=encode-for-uri(data:normalize-resource-title(xmldb:decode-uri($old-name), false()))
let $rename := $old-name || "->" || $new-name
let $do-it := if ($old-name != $new-name) then xmldb:rename($collection, $old-name || ".xml", $new-name || ".xml") else ()
return (),
let $dreindex := didx:reindex(collection("/db/data/notes"))
let $rreindex := ridx:reindex(collection("/db/data/notes"))
let $reidx := xmldb:reindex("/db/data/notes")
return ()
)

@EfraimFeinstein
Copy link
Member Author

Ran on prod 11/2/2021 (before backup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant