Browse Source

fix: migration

Tienson Qin 1 year ago
parent
commit
31ffe5ae8d

+ 9 - 4
deps/db/src/logseq/db/frontend/content.cljs

@@ -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."

+ 3 - 3
src/main/frontend/worker/db/migrate.cljs

@@ -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'})))))