Skip to content

Commit

Permalink
fix: migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Nov 30, 2024
1 parent af31d3d commit 31ffe5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions deps/db/src/logseq/db/frontend/content.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
[logseq.common.util :as common-util]
[logseq.db.frontend.entity-util :as entity-util]))

#_(defonce page-ref-special-chars "~^")

(defonce id-ref-pattern
#"\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]")
;; [[uuid]]
(def id-ref-pattern
(re-pattern
(str
"\\[\\["
"("
common-util/uuid-pattern
")"
"\\]\\]")))

(defn content-id-ref->page
"Convert id ref backs to page name using refs."
Expand Down
6 changes: 3 additions & 3 deletions src/main/frontend/worker/db/migrate.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@
(re-find db-content/id-ref-pattern v))
[:db/retractEntity e]

(string/includes? v (str ref-special-chars page-ref/left-brackets))
(let [title' (string/replace v (str ref-special-chars page-ref/left-brackets) page-ref/left-brackets)]
(string/includes? v (str page-ref/left-brackets ref-special-chars))
(let [title' (string/replace v (str page-ref/left-brackets ref-special-chars) page-ref/left-brackets)]
(prn :debug {:old-title v :new-title title'})
{:db/id e
:block/title title'})

(re-find id-ref-pattern v)
(let [title' (string/replace v id-ref-pattern (page-ref/->page-ref "$1"))]
(let [title' (string/replace v id-ref-pattern "$1")]
(prn :debug {:old-title v :new-title title'})
{:db/id e
:block/title title'})))))
Expand Down

0 comments on commit 31ffe5a

Please sign in to comment.